sass / node-sass

:rainbow: Node.js bindings to libsass
https://npmjs.org/package/node-sass
MIT License
8.51k stars 1.32k forks source link

--include-path not working anymore in 4.4.0 #1876

Closed olivierbossel closed 7 years ago

olivierbossel commented 7 years ago
{ http_parser: '2.7.0',
  node: '6.9.4',
  v8: '5.1.281.89',
  uv: '1.9.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '57.1',
  modules: '48',
  openssl: '1.0.2j' }

Hi there,

Just to point out that the --include-path seems to not work anymore from this version. It was working in the node-sass 4.3.0 but not in the 4.4.0... When I import some node_modules sass like:

@import "node_modules/modularscale-sass/stylesheets/modular-scale";

it is yielding that the file is not readable. It works if I force the 4.3.0 version...

Hope this is not something to big to fix... Let me know :)

Cheers guys, thanks for your work it's quite awesome!

Best regards

Olivier Bossel

kaelig commented 7 years ago

I have an issue probably related to this as well. I'm using gulp-sass though.

I have to specifically write @import '../../node_modules/my-module/index'; instead of node_modules/my-module/index which used to work.

nschonni commented 7 years ago

@olivierbossel can you provide a minimal project that reproduces this along with with the actual command line and log

nschonni commented 7 years ago

@kaelig ... isn't a valid path navigator. Try switching it to ..

kaelig commented 7 years ago

@nschonni I updated my comment.

Here's a project you can test my issue in: https://github.com/salesforce-ux/design-system-starter-kit

Steps to reproduce:

  1. git clone https://github.com/salesforce-ux/design-system-starter-kit.git
  2. git checkout b3293e8b2f1f1bd9a1bb0c2174885cb4c4d99b81
  3. npm install
  4. npm run dev

This error pops up:

Error in plugin 'sass'
Message:
    src/styles/index.scss
Error: File to import not found or unreadable: node_modules/@salesforce-ux/design-system/scss/index.
       Parent style sheet: /Users/kdeloumeauprigent/workspace/salesforce/design-system-starter-kit/src/styles/index.scss
        on line 9 of src/styles/index.scss
>> @import 'node_modules/@salesforce-ux/design-system/scss/index';
   ^
nschonni commented 7 years ago

@kaelig you're not providing any value for includePath in your Gulp config. node_modules isn't automatically added to include paths anymore (or hasn't been for awhile AFIAK).

kaelig commented 7 years ago

I thought the current directory was supposed to be in the includePaths by default (in that case: the root of the project from which the script is called)?

nschonni commented 7 years ago

I thought the current directory was supposed to be in the includePaths by default

No, https://github.com/sass/node-sass#includepaths. That causes problems because then it starts to try and pick up random packages (accidentally) published components.

kaelig commented 7 years ago

@nschonni node-sass src/styles/index.scss works like a charm though. Is there something I'm missing here? Could it be related to gulp-sass directly?

xzyfer commented 7 years ago

Sorry the delayed response, Australian timezone and such. This is a bug. There was an unnecessary breaking change in LibSass regarding load paths. I missed this in the release notes for LibSass and forgot to compensate for it in node-sass.

xzyfer commented 7 years ago

I thought the current directory was supposed to be in the includePaths by default

This is kind of true.

@nschonni is correct in that node-sass isn't doing this.

LibSass was internally adding the cwd of the entry file to it's internal search path, which is similar to user defined load paths. This was removed in LibSass 3.5.0 release line. Node Sass needs to be updated to shim the old behaviour for the time being.

Could it be related to gulp-sass directly

@kaelig gulp-sass does add the cwd to the load path.

xzyfer commented 7 years ago

It's not clear to me why you're experiencing the issue with gulp-sass and not node-sass. I would expect the inverse to be true. I'll have to investigate tonight.

azizur commented 7 years ago

I am seeing this same issue as well. At first, I thought it as my gulp project where I am making lots of change so frequently.

xzyfer commented 7 years ago

A work around for now is adding the cwd to your includePaths.

azizur commented 7 years ago

You mean set SASS_PATH=. in your shell's environment.?

xzyfer commented 7 years ago

No, I mean in the includePaths array in the render/renderSync config object, or the gulp-sass config object.

gulp.src('./scss/*.scss')
  .sass({ includePaths: ['./scss'])
  .dest('./dest')
olivierbossel commented 7 years ago

Hi there,

Sorry for the delay (Switzerland timezone...). Thanks for the quick response guys, seems that it's not an isolated issue. Did you need some help or that I post a demo project that has the issue?

Let me know! :)