Node-sass: Inconsistent behavior when using directory input with --watch and without --watch

Created on 24 Oct 2016  路  12Comments  路  Source: sass/node-sass

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
Bug - Confirmed Module - Watcher

All 12 comments

resolved?

if the issue still open it's not resolved.

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

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

This looks like a bug I introduced in https://github.com/sass/node-sass/pull/1078. We should not be watching .css files.

Is there a workaround for this bug?

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?

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.

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.

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liuyuqiang picture liuyuqiang  路  3Comments

NathanKleekamp picture NathanKleekamp  路  4Comments

paulcpederson picture paulcpederson  路  3Comments

samayo picture samayo  路  3Comments

alexandrubau picture alexandrubau  路  3Comments