Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Imported files outside the source directory built when changed in watch mode #2491

Open
@paulcpederson

Description

@paulcpederson

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++]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions