Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Inconsistent behavior when using directory input with --watch and without --watch #1758

Open
lephuongbg opened this issue Oct 24, 2016 · 12 comments

Comments

@lephuongbg
Copy link

lephuongbg commented Oct 24, 2016

Current behavior

  • When using directory input without --watch, all .scss files will be compiled and normal css files won't be compiled.
  • When using directory input with --watch, when any css file changed, they will be compiled.

Suggested behavior

When using directory input with --watch, we should watch .scss files only.


  • NPM version (npm -v): 3.10.3
  • Node version (node -v): 6.3.1
  • node-sass version (node -p "require('node-sass').info"): 3.10.1
@wuzhouyang
Copy link

resolved?

@xzyfer
Copy link
Contributor

xzyfer commented Nov 4, 2016

if the issue still open it's not resolved.

@nschonni
Copy link
Contributor

nschonni commented Nov 4, 2016

Only watching SASS/SCSS files appears to be in the current code https://github.com/sass/node-sass/blob/master/bin/node-sass#L135

@nschonni
Copy link
Contributor

nschonni commented Nov 4, 2016

Nevermind, it looks like the watcher does look for css here https://github.com/sass/node-sass/blob/master/bin/node-sass#L243

@xzyfer
Copy link
Contributor

xzyfer commented Nov 7, 2016

This looks like a bug I introduced in #1078. We should not be watching .css files.

@nschonni nschonni added this to the 3.12.0 milestone Nov 8, 2016
@kibbled
Copy link

kibbled commented Nov 29, 2016

Is there a workaround for this bug?

@eugeneglova
Copy link

eugeneglova commented Dec 19, 2016

hey @xzyfer could you just make these extensions to be configurable so I can remove css from that lis as a workaround for this issue. Should I create PR for that?

@xzyfer
Copy link
Contributor

xzyfer commented Dec 19, 2016

They cannot be configured. They live in LibSass. The decisions has been made to keep the current behaviour until Sass 4's module system is ready. Removing this now will break lots of people's code.

@kibbled
Copy link

kibbled commented Dec 22, 2016

This bug sort of causes infinite compiles to happen when you watch a directory because after SCSS files compile to CSS, the watcher detects changes and recompiles the CSS which starts a vicious cycle Perhaps a recommendation in the documentation for using a different directory for your CSS files from your SCSS files since it's unusable in the current form.

@RoyTinker
Copy link

Looks like the best workaround is to use node-sass-chokidar.

@xzyfer
Copy link
Contributor

xzyfer commented Dec 13, 2017

So I think the reasonable workaround for this is for node-sass to not treat .css as entry points.

We still need to watch .css files, this is unavoidable with breaking things for users, but we should only trigger compilations for CSS files that are imported by scss files.

This is a patch I think wen can ship before the 5.0 bump and should fix the majority of issues around watching css files.

@RoyTinker
Copy link

@xzyfer is this still planned for a pre-5.0 patch?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants