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

Imports don't seem to get recompiled

Open achalddave opened this issue 13 years ago • 19 comments

If I have a file index.scss which has @import "common.scss", and change common.scss, index.scss doesn't seem to get recompiled.

The relevant code seems to be in the following locations:

checkImports is called here, and defined here.

It relies on imports[path], which only seems to be assigned here to an empty list. I can't seem to find any code that detects imported files -- am I missing something?

achalddave avatar Sep 26 '13 00:09 achalddave

@achalddave Is this still happening in the latest version of node-sass, v0.6.7?

andrew avatar Oct 19 '13 14:10 andrew

I'll try to test this as soon as I can, but in the current master I don't see imports[path] being assigned to anything but an empty list... am I missing something?

achalddave avatar Oct 20 '13 05:10 achalddave

Does not work as of version 0.7.0-alpha. I can try to revert to 0.6.7 and try it later -- this is the version npm automatically updated to.

achalddave avatar Oct 20 '13 05:10 achalddave

If it doesn't work in 0.7.0-alpha then I doubt it will work in 0.6.7 either, I'll try and take a look at this one this week.

andrew avatar Oct 20 '13 05:10 andrew

Yeah, I assumed so as well. I looked at it a while back and couldn't figure it out. imports doesn't seem to be set anywhere as I mentioned before, and I couldn't even figure out where you could get the imported paths from the back end (specifically, in Render). I couldn't spend too much more time on it, though, so I may have missed something obvious.

achalddave avatar Oct 20 '13 18:10 achalddave

How are you running the command? If you don't have a --watch on the file, it won't get recompiled. You can pass the force flag into the middleware if you don't want the middleware caching the previous set of results.

deanmao avatar Jan 03 '14 05:01 deanmao

I recently had my laptop stolen so I'm not able to test this right now and get back to you. But I was using it as middleware (I will try to find the repo where I was using it and point it out when I'm on a computer). The issue was that it was caching when it shouldn't be. I did end up using the force flag, but it seems that if an imported file is changed, the middleware should recompile the original CSS file. In fact, it seems the code attempts to do this, but some bug renders it useless, as I pointed out in the original comment.

achalddave avatar Jan 04 '14 21:01 achalddave

The code that reads the import file paths are actually inside of libsass. It's possible the bug is there, but I would've expected a long more people to have this problem if it were actually broken in the native library.

deanmao avatar Jan 04 '14 22:01 deanmao

Oh, you're right, it's probably more likely that I read the code incorrectly; just pointing out what I thought I saw. Will take a closer look later; does it work for you? I.e. If you change an imported file, does it automatically recompile the file you're importing it from?

achalddave avatar Jan 04 '14 22:01 achalddave

No, it doesn't. I have to manually watch all the files that I intend to change during development or else it won't recompile it for me automatically. Although node-sass "looks" like it will handle everything, it only passes all the parameters to the native library that does everything else. We tend to get bugs that should have be filed with libsass because most don't realize that node-sass is not the actual sass compiler.

deanmao avatar Jan 04 '14 23:01 deanmao

Hm, okay. I guess I'll check with libsass then. The thing is, node-sass seems to do some prechecking about what has changed before passing it to libsass, and it seemed to me like these imported files were simply not repassed to libsass. At any rate, I know very little about either code base, just what I read into when I filed this issue, so you likely know more. If you're sure this is a libsass bug, feel free to close it and I can report it there.

achalddave avatar Jan 05 '14 00:01 achalddave

I haven't read the code thoroughly but I guess this feature is not possible without my pull-request #290 since we need to know which files have been imported to watch them. But this feature can probably be implemented when #290 is finished.

jhnns avatar Apr 20 '14 23:04 jhnns

@jhnns I'm having the same problem with node-sass 0.9.3. Has it been identified whether it's a node-sass issue or a libsass issue? Will this be fixed in version 0.10.0 (which looks like it'll include your PR referenced above)?

In the meanwhile, it looks like setting up a grunt task to watch all files is the way to go so I'm gonna try that.

jkodroff avatar Aug 29 '14 14:08 jkodroff

I guess the relevant code for it is here. Are you running node-sass via the command line?

My pull-request has already been merged some time ago, but the cli watcher has not been updated. Currently it only watches the current file or the given directories. You could change the behavior to update the watched directories depending on the imported files.

jhnns avatar Sep 01 '14 13:09 jhnns

:+1: I have the same problem here.

maximeaubaret avatar Sep 24 '14 14:09 maximeaubaret

I've just encountered this problem too. The CSS isn't recompiled if an imported SCSS file changes. This seems to be the case both with files imported locally and from directories set using:

includePaths

I'm using sass.middleware

But, using

force: true

is a good workaround

swervo avatar Oct 09 '14 16:10 swervo

Hey guys, v2.0.0-beta is just released. Is it still happening?

FWIW, middleware function is removed from node-sass now (not even the deprecated warning would appear).

See release notes for breaking changes.

am11 avatar Dec 25 '14 00:12 am11

npm install [email protected] is released! Checkout the release notes: https://github.com/sass/node-sass/releases/tag/v2.0.0

am11 avatar Feb 12 '15 04:02 am11

Yay! :checkered_flag:

jhnns avatar Feb 12 '15 13:02 jhnns