Imported files outside the source directory built when changed in watch mode
I have a fix for this, will try to pr shortly. It's kind of an edge case, but replication is fairly straight forward.
Assume we have the following file tree:
src/
file1.scss
file2.scss
dist/
library/
include.scss
And file1 imports the library, like this:
@import "library/include";
We build all the sass files in src/ with the CLI using node-sass src/ -o dist/. This works correctly.
If, we watch for changes and change the files in src, it also still works correctly.
But if we change library/include.scss, the CLI will build a new file at library/include.css. Then, node-sass will throw an error:
It's not clear which file to import for '@import "library/include".
Candidates:
library/include.scss
library/include.css
Even though it is outside the source directory, it's included in the watched files, and because it doesn't have an underscore preceding it's name, we render it to the default location (right next to itself).
The fix is pretty simple, basically when using a directory for multiple file compilation, when files change, check that they are actually inside the directory before rendering. I added multiple file compilation once upon a time so this is mostly my fault 😬 I'll try to get a pr for this fix in soon.
- NPM version (
npm -v): 6.4.0 - Node version (
node -v): v8.2.1 - Node Process (
node -p process.versions):
{ http_parser: '2.7.0',
node: '8.2.1',
v8: '5.8.283.41',
uv: '1.13.1',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
openssl: '1.0.2l',
icu: '59.1',
unicode: '9.0',
cldr: '31.0.1',
tz: '2017b' }
- Node Platform (
node -p process.platform): darwin - Node architecture (
node -p process.arch): x64 - node-sass version (
node -p "require('node-sass').info"):
node-sass 4.9.3 (Wrapper) [JavaScript]
libsass 3.5.4 (Sass Compiler) [C/C++]
- npm node-sass versions (
npm ls node-sass): [email protected]
pr submitted
I think I may be seeing a related issue. My command:
node-sass --include-path 'node_modules/@salesforce-ux/design-system/scss' --source-map true sass/ -wo app/styles
has started hanging. If I run the same command without the -w flag it completes correctly. I'm guessing it is trying to compile files outside of the source directory - maybe in the include path?
I'm sorry I can't be more precise here. If you can give me a hint how I can diagnose this more effectively I'm happy to do this.
node -v 8.12.0
npm -v 6.4.1
node-sass 4.9.3 (Wrapper) [JavaScript]
libsass 3.5.4 (Sass Compiler) [C/C++]```
@swervo if you point node-sass in your package.json to paulcpederson/node-sass#watch-directory and npm install again does the command work?
@paulcpederson I tried that. It's the same. I think I am seeing a different problem. Here are the symptoms that I'm seeing with both your version and the node-sass 4.9.3:
- If I do a compile without the watcher it does it instantaneously.
- If I activate the watcher and make a change in an imported partial it compiles instantaneously.
- If I activate the watcher and make a change in the root sass file (that is basically building
node_modules/@salesforce-ux/design-system/scss) it does complete but it takes about 5 minutes and my fan comes on. So something definitely isn't quite right here but it may not be related to what you're seeing.
Apologies if I've taken you off track.