Node-sass: watching newly created files

Created on 10 Feb 2017  ·  17Comments  ·  Source: sass/node-sass

Greetings!
When I start node-sass in recursive watching mode it works just fine with the exception that newly created files are not being watched.
For example, if I wach a directory and I add new _styles.scss_ file, node-sass ignores this file, providing the process has already been started before.
Is it possible to change this behavior? Or do I just miss something?

Feature - Request Module - Watcher

Most helpful comment

This is a know issue. I'll make a patch in the next release

On 12 Feb. 2017 11:24 am, "Dan Abramov" notifications@github.com wrote:

I can also reproduce this on OS X Sierra with [email protected].
My command looks like this:

node-sass src/ -o src/ --watch --recursive

Adding src/wow.scss (and saving it multiple times) has no effect until I
restart the watcher, at which point it works as intended for this file (but
not for any new files).


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sass/node-sass/issues/1891#issuecomment-279186397,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjZWLKioJ_rxpM7QIRE8D7Ty5njyS_Fks5rblEggaJpZM4L9BgX
.

All 17 comments

I can also reproduce this on OS X Sierra with [email protected].
My command looks like this:

node-sass src/ -o src/ --watch --recursive

Adding src/wow.scss (and saving it multiple times) has no effect until I restart the watcher, at which point it works as intended for this file (but not for any new files).

I also tried removing the --recursive flag but it doesn’t seem to have any effect.

This is a know issue. I'll make a patch in the next release

On 12 Feb. 2017 11:24 am, "Dan Abramov" notifications@github.com wrote:

I can also reproduce this on OS X Sierra with [email protected].
My command looks like this:

node-sass src/ -o src/ --watch --recursive

Adding src/wow.scss (and saving it multiple times) has no effect until I
restart the watcher, at which point it works as intended for this file (but
not for any new files).


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sass/node-sass/issues/1891#issuecomment-279186397,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjZWLKioJ_rxpM7QIRE8D7Ty5njyS_Fks5rblEggaJpZM4L9BgX
.

Specifically the added event does not rebuild the watch graph so the
watcher doesn't know the new file exists.

On 12 Feb. 2017 12:04 pm, "Michael Mifsud" xzyfer@gmail.com wrote:

This is a know issue. I'll make a patch in the next release

On 12 Feb. 2017 11:24 am, "Dan Abramov" notifications@github.com wrote:

I can also reproduce this on OS X Sierra with [email protected].
My command looks like this:

node-sass src/ -o src/ --watch --recursive

Adding src/wow.scss (and saving it multiple times) has no effect until I
restart the watcher, at which point it works as intended for this file (but
not for any new files).


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sass/node-sass/issues/1891#issuecomment-279186397,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjZWLKioJ_rxpM7QIRE8D7Ty5njyS_Fks5rblEggaJpZM4L9BgX
.

Thanks for such a quick response!
👍

I wonder if you could possibly reconsider #1369 at the same time? I believe it would improve consistency across the board.

With #1369 implemented - all files are guaranteed to be in a compiled state whether they already existed or were created while watching.
Without it - files that already exist are not compiled. Files that are created while watching are compiled. This seems inconsistent and fiddly to manage.

Thanks for your consideration.

@xzyfer Hiya. Appreciate this fix! I cloned and cherry picked the commit to give it a test (and tried master additionally) but while it now picks up .css additions, it's still not picking up and compiling new .scss files. This is on Mac OS X El Capitan. Any ideas?

I see, it seems only to be looking for files linked in from JavaScript. So in the case where we're including .css but generating it via node-sass from _new_ .scss files (created while the build process is already running), this wouldn't work.

Our use case on a creating a new file is to create a .scss file, which we'd want automatically compiled to .css without having to restart the build process. I suppose I could monkey patch the code to handle our specific case, but perhaps there is a more general approach.

@Deimoslink Per the comment above, are you still having the same issue?

@xzyfer Even more unfortunate, our existing .scss files, when edited, are no longer compiled into .css. So this is a wonderful fix if you're editing and using .css directly, but if you're using .scss compiled to .css it has the same issue as before and introduces a regression.

TO BE CLEAR and I should have said this before, we're using create-react-app and so if its configuration needs to change, we haven't yet done that.

This issue was closed but was not actually resolved. I'm running v4.9.4 on OSX 10.12.2 (Sierra) and the problem persists, exactly as described by @gaearon

node-sass-chokidar doesn't suffer from this issue, at least on my machine. From what I understand the only difference between the two is that nsc uses chokidar instead of Gaze to watch files, but I'm totally out of my depth here.

This issue was closed but was not actually resolved

Not resolved in july 2019 either (running Linux), but still 'Closed' on github unfortunately :(

I'm still having this problem, Oct 2019. Running Mac OS Mojave. Please think of reopen this

@mankinchi can you build a simple repository with a script to demonstrate this?

Same problem, January 2020.

Same problem, February 2020. Any solution?

Having exactly the same issue. Using latest node-sass 14.4.1 (July 2020) and Windows 8.1 machine. Still no solution?
Here is how my command looks like: node-sass sass/main.scss css/style.css -w --recursive

update: ended up installing node-sass-chokidar and now everything works as it should

Also having this exact issue. Thanks @t-kowalewski just swapped to node-sass-chokidar and it's now working fine!

Same here with Node 12.18.3 and node-sass 4.14.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robcalcroft picture robcalcroft  ·  40Comments

xzyfer picture xzyfer  ·  39Comments

mrking picture mrking  ·  60Comments

mafintosh picture mafintosh  ·  46Comments

danez picture danez  ·  39Comments