maoberlehner / node-sass-magic-importer

Custom node-sass importer for selector specific imports, module importing, globbing support and importing files only once.
MIT License
292 stars 28 forks source link

Package imports with scoped packages don't work on Windows #182

Closed fafnirical closed 5 years ago

fafnirical commented 5 years ago

I can provide an example repo if necessary, but in particular I encountered this issue when trying to load Sass files from @glidejs/glide:

@import '~@glidejs/glide/src/assets/sass/glide.core';

I get the following error:

Error: File to import not found or unreadable: ~@glidejs/glide/src/assets/sass/glide.core
maoberlehner commented 5 years ago

Hey @fafnirical,

node-sass-magic-importer and node-sass-package-importer do work with scoped packages.

I've tried the following to reproduce your problem, but everything worked as expected:

npm init
npm install node-sass-package-importer node-sass @glidejs/glide
echo '@import "~@glidejs/glide/src/assets/sass/glide.core";' > test.scss
npx node-sass --importer node_modules/node-sass-package-importer/dist/cli.js -o ./ test.scss
# A file test.css is generated with the contents of glide.core.scss 

Please provide additional informations on how you initialized the importer package. Thx.

fafnirical commented 5 years ago

@maoberlehner, I've created an example repo where I'm able to reproduce the issue: https://github.com/fafnirical/node-sass-magic-importer-issue-182

For additional context, I'm using Node v10.11.0, npm v6.4.1, and Windows 10.

maoberlehner commented 5 years ago

Works on my machine™ so I guess it has something to do with Windows. I have to admit, although I did run it once or twice on Windows, I almost exclusively develop and test this code on macOS. Usually I take care of handling file paths in a way that works cross OS but it seems I overlooked something.

I'll investigate. Pull requests are also welcome!

maoberlehner commented 5 years ago

Btw. thank you @fafnirical for taking the time to create the repository. If people take the time to provide code examples, it helps a lot!