Search code examples
csssasscommand-line-interfacenode-sass

Node sass watch builds changed file directly instead of entry point file


I'm trying to use a simple script with node-sass v4.8.3 which builds my SASS code:

./node_modules/node-sass/bin/node-sass ./sass/import.scss source/css/style.css --watch

If I use it without the --watch flag it works perfect, but when the watcher is active, if I change a file which is not ./sass/import.scss, for example./sass/components/button.scss, it seems the compiler tries to build it directly, without starting from ./sass/import.scss.

Is that true?

Does exists some way to avoid this and tell the watcher to build ./sass/import.scss every time?


Solution

  • You told sass to watch only the import.scss file. See the documentation for all the command line options you need and remember to let the included filenames to start with an "_" to prevent that they get compiled to a css single file as well.

    node-sass --recursive --watch ./sass/ --output source/css/