node-sass icon indicating copy to clipboard operation
node-sass copied to clipboard

watching newly created files

Open Deimoslink opened this issue 8 years ago • 18 comments

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?

Deimoslink avatar Feb 10 '17 05:02 Deimoslink

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.

gaearon avatar Feb 12 '17 00:02 gaearon

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

On 12 Feb. 2017 11:24 am, "Dan Abramov" [email protected] 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 .

xzyfer avatar Feb 12 '17 01:02 xzyfer

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" [email protected] wrote:

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

On 12 Feb. 2017 11:24 am, "Dan Abramov" [email protected] 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 .

xzyfer avatar Feb 12 '17 01:02 xzyfer

Thanks for such a quick response! 👍

gaearon avatar Feb 12 '17 02:02 gaearon

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.

NigeNigeNige avatar Feb 28 '17 15:02 NigeNigeNige

@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.

adamdonahue avatar Jul 30 '17 17:07 adamdonahue

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

adamdonahue avatar Jul 30 '17 17:07 adamdonahue

@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.

adamdonahue avatar Jul 30 '17 17:07 adamdonahue

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.

kylebebak avatar Nov 01 '18 22:11 kylebebak

This issue was closed but was not actually resolved

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

Friksel avatar Jul 09 '19 19:07 Friksel

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

mankinchi avatar Oct 18 '19 04:10 mankinchi

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

saper avatar Oct 18 '19 13:10 saper

Same problem, January 2020.

baglio avatar Jan 08 '20 16:01 baglio

Same problem, February 2020. Any solution?

diegoulloao avatar Feb 11 '20 05:02 diegoulloao

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

t-kowalewski avatar Jul 22 '20 14:07 t-kowalewski

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

Mofunkles avatar Oct 20 '20 02:10 Mofunkles

Same here with Node 12.18.3 and node-sass 4.14.1

bago2k4 avatar Nov 16 '20 19:11 bago2k4

issue still exists :(

Node 21 and node-sass 9.0

pavelee avatar Oct 26 '23 19:10 pavelee