After my experiments (#1852) I found that node-sass -w input.scss > output.css is a wrong way to go (due to POSIX file descriptors redirection logic).
So currently there is no way to output changes into a single file when using --watch option.
npm -v): 3.10.3node -v): v6.3.0node -p process.versions):{ http_parser: '2.7.0',
node: '6.3.0',
v8: '5.0.71.52',
uv: '1.9.1',
zlib: '1.2.8',
ares: '1.10.1-DEV',
icu: '57.1',
modules: '48',
openssl: '1.0.2h' }
node -p process.platform): darwinnode -p process.arch): x64node -p "require('node-sass').info"):node-sass 4.1.1 (Wrapper) [JavaScript]
libsass 3.4.0 (Sass Compiler) [C/C++]
npm ls node-sass): [email protected]What are you suggesting?
Maybe to allow -o file.css? (or some new argument for that).
I see. We do have an -o flag but I believe it only works when watching a directory. It makes sense that it should work individual files as well
I came across this today. Even when pointing the input to one file, it watches the whole directory (seemed to be recursive even though I didn't have the -r flag) and creates a .css file in my output directory FOR EACH FILE.
So node-sass --watch sass/styles.scss --output css didn't just create css/styles.css it created a css file for everything in sass/.
Even without the option for -o filename.css why would it create an output file for anything but my entry? Everything is imported in that one styles.scss, so now I have a ton of extra files dirtying the project. The other option being to not use watch.
Note: you can get around this somewhat by prefixing all imported sass files with a _ which lets sass know it is a partial and should not be generated into a css file.
Even when using folder watch, node-sass don't create the output file until I make a change:
node-sass --watch template/ --output template/style.css
I only have style.scss in template/ folder, and the css file is never created, until I make a change on my scss file. Using node-sass --watch template/ --output template/ don't work either.
(osx platform, latest node-sass version)
What about this:
node-sass -w in/main.scss out/main.css
This works for me as of 4.12. There are some issues like https://github.com/sass/node-sass/issues/2491 or https://github.com/sass/node-sass/issues/2560 but in the most general case it works.
The problem was that I had multiple files to watch for changes but only one file to recompile.
So this is the same as this https://github.com/sass/node-sass/pull/2492#issuecomment-543409242 I think
Most helpful comment
Note: you can get around this somewhat by prefixing all imported sass files with a
_which lets sass know it is a partial and should not be generated into a css file.