You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only way to get this to work is to use LoaderOptionsPlugin
new webpack.LoaderOptionsPlugin({
options: {
context: '/', // <- putting this line right under "options" did the trick
sassLoader: {
includePaths: [
path.resolve(__dirname, 'vendor/zurb/foundation/scss'),
path.resolve(__dirname, 'node_modules/motion-ui/src'),
path.resolve(__dirname, 'resources/assets/sass')
]
}
}
})
Otherwise it throws an error saying can't import 'foundation' and so on. LoaderOptionsPlugin stops to work as of version 5.0.
Reacted by Greg Venech, Alexander Akait, Renald Laranjeira, Giuseppe Rodriguez, Sertaç Onay, Steve Davies and Chris Hough
@asolopovas includePaths work fine for me in 4.1.1: new webpack.LoaderOptionsPlugin({ options: { sassLoader: { includePaths: [ path.resolve(__dirname, '../src/app/assets/sass'), path.resolve(__dirname, '../node_modules/bootstrap/scss') ] } } })
@asolopovas with sass-loader 4.1.1 and webpack 2.2.1, both config examples work.
With sass-loader 5.0.1, webpack.config.js does not work because the sass-loader doesn't read the config from the webpack options object anymore. You don't need to use the LoaderOptionsPlugin with sass-loader 5.0.0 anymore. Just specify the loader options directly. Thus, webpack.config.error.jsdoes work.
@jhnns I have tried webpack 2.2.1 with both [email protected] and [email protected] both throw an error if I place includePaths into options of sass loader like that:
@jhnns yea I'm not dependent on this issue anymore as our infrastructure changed, but, when I was, I tested v5.0.0 with both the options and using the LoaderOptionsPlugin (which I know you said doesn't work intentionally) and using just options failed as well iirc.
Ok, now I can reproduce this error on Windows (doesn't happen on macOS):
ERROR in E:/temp/sass-loader-test/~/css-loader?{"sourceMap":true}!E:/temp/sass-loader-test/~/sass-loader/lib/loader.js?{"sourceMap":true,"includePaths":["E://temp//sass-loader-test//~//foundation-sites//scss","E://temp//sass-loader-test//~//motion-ui//src","E://temp//sass-loader-test//resources//assets//sass"]}!../sass/app.scss
Module build failed: Error: "../../node_modules/foundation-sites/scss/foundation.scss" is not in the SourceMap.
at BasicSourceMapConsumer.SourceMapConsumer_sourceContentFor [as sourceContentFor] (E:\temp\sass-loader-test\node_modules\source-map\lib\source-map-consumer.js:704:13)
at SourceMapGenerator.<anonymous> (E:\temp\sass-loader-test\node_modules\source-map\lib\source-map-generator.js:235:40)
at Array.forEach (native)
at SourceMapGenerator_applySourceMap [as applySourceMap] (E:\temp\sass-loader-test\node_modules\source-map\lib\source-map-generator.js:234:32)
at MapGenerator.applyPrevMaps (E:\temp\sass-loader-test\node_modules\postcss\lib\map-generator.js:146:22)
at MapGenerator.generateMap (E:\temp\sass-loader-test\node_modules\postcss\lib\map-generator.js:194:46)
at MapGenerator.generate (E:\temp\sass-loader-test\node_modules\postcss\lib\map-generator.js:297:25)
at LazyResult.stringify (E:\temp\sass-loader-test\node_modules\postcss\lib\lazy-result.js:296:24)
at E:\temp\sass-loader-test\node_modules\postcss\lib\lazy-result.js:233:27
at process._tickCallback (internal/process/next_tick.js:103:7)
@ ../sass/app.scss 4:14-151
@ ./app.js
@ multi ./app
It seems like node-sass is exporting source maps with forward slashes (which are also valid on Windows). Webpack's source map module, however, stores backslash paths. That's why the source maps can not be resolved.
I can fix this in sass-loader by applying path.normalize on all source map paths.
Next time, please always post the actual error message including the stack trace.
@jhnns I have updated my sass-loader-test and it confirms that something is not right, the problem seems to be with vue-loader or sass-loader as they don't seem to work together. If I import 'foundation' via app.js file things work fine, if I do import foundation from withing vue component things begin to break down. But most recent vue-loader still works fine with [email protected] and LoaderOptionsPlugin with the same setup where I @import 'foundation' from within component.
I don't know what the vue-loader is doing, but if I remove the sass-loader and just try to compile App.vue the same error is still there. So this is not related to the sass-loader.
A hack solution is definitely better then no solution thanks
Oh, I don't think that this is a hack solution. Since a vue file can host a lot of file types, it makes sense to have a dedicated loader pipeline because webpack's loader test algorithm wouldn't work here.
Well vue references the file format in style section and utilises sass-loader, so I do not see the reason why it can't read setting from inside sass-loader options, it's successfully does that from babel and typescript loaders. So it's either some adjustments could be done to sass-loader or to vue-loader and as I have noticed mac users do not complain about this issue. I might be wrong anyhow. It just feels wierd to concentrate includePaths inside vue loader pipeline.
On 28 Feb 2017, 12:55, at 12:55, Johannes Ewald ***@***.***> wrote:
> A hack solution is definitely better then no solution thanks
Oh, I don't think that this is a hack solution. Since a `vue` file can
host a lot of file types, it makes sense to have a dedicated loader
pipeline because webpack's loader `test` algorithm wouldn't work here.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#366 (comment)
If you have a .babelrc or a tsconfig.json inside your root folder, they are reading the config from these files. But this is loader specific since the tools behind these loaders (babel and typescript) have the same style of configuration. It doesn't apply to all loaders.
@jhnns Thank you a lot for this library, and your support. I understand your point, I think that vue-loader with their custom pipeline could added a feature that if no additional setting provided into the pipeline, vue-loader could use default options from sass loader config, that would be definitely convenient.
hey guys , i found a new way for importing slick and slick.scss it is so simple:
(1) just go inside of your node_modules folder and find slick-carousel folder
(2) inside of that find slick.scss and slick-theme.scss from slick folder and open them up
(3) create two seperate files with names of _slick.scss and _slickTheme.scss inside of your style folders of your project
(4) copy all from slick.scss and slick-theme.scss and put them in your newly created files ( _slick.scss and _slickTheme.scss )
(5) import them in your app.scssfile
(6) now if you are using webpack like me , i'm guessing that you getting can't resolve './ajax-loader.gif' error and a cant resolve font error after that
(7) in fact those files is been used by slick-carousel css it self and for that we can just simple go inside your newly created _slickTheme.scss and find these lines
Activity
pamtbaau commentedon Feb 7, 2017
@asolopovas Same issue here after upgrading to 5.0.0. Your suggested solution did not fix mine elas... Rolled back to 4.1.1 and issue disappeared.
asolopovas commentedon Feb 7, 2017
@pamtbaau solution works on 4.1.1, I am not suggesting that it does on 5. But version 4.1.1 does not work with options.includePaths either.
pamtbaau commentedon Feb 7, 2017
@asolopovas includePaths work fine for me in 4.1.1:
new webpack.LoaderOptionsPlugin({ options: { sassLoader: { includePaths: [ path.resolve(__dirname, '../src/app/assets/sass'), path.resolve(__dirname, '../node_modules/bootstrap/scss') ] } } })asolopovas commentedon Feb 7, 2017
@pamtbaau if you read through documentation you will see that it should be working without LoaderOptionsPlugin, that's the point I am trying to make.
skipjack commentedon Feb 7, 2017
+1 I'm running into this as well -- on 5.0.0 even the suggested
webpack.LoaderOptionsPluginsolution doesn't seem to be working.jhnns commentedon Feb 7, 2017
The
LoaderOptionsPluginshould not be necessary, see my comment here.We have a test for
includePaths. It should work the way you described it. Could you create a minimal example repo that reproduces the error?asolopovas commentedon Feb 7, 2017
I will tomorrow
asolopovas commentedon Feb 9, 2017
@jhnns here you go I have created two webpack configs one that works second one that fails
https://github.com/asolopovas/sass-loader-test
coolhihi commentedon Feb 11, 2017
Thank you. I use
LoaderOptionsPluginand rollback sass-loader to 4.1.1. It work.jhnns commentedon Feb 13, 2017
@asolopovas with sass-loader 4.1.1 and webpack 2.2.1, both config examples work.
With sass-loader 5.0.1,
webpack.config.jsdoes not work because the sass-loader doesn't read the config from the webpack options object anymore. You don't need to use theLoaderOptionsPluginwith sass-loader 5.0.0 anymore. Just specify the loader options directly. Thus,webpack.config.error.jsdoes work.jhnns commentedon Feb 13, 2017
Also check out our tests.
asolopovas commentedon Feb 13, 2017
@jhnns I have tried webpack 2.2.1 with both [email protected] and [email protected] both throw an error if I place includePaths into options of sass loader like that:
Which has not worked in the repository provided in webpack.config.error.js, I tested it on windows 10 x64 machine so clearly something fails.
skipjack commentedon Feb 13, 2017
@jhnns yea I'm not dependent on this issue anymore as our infrastructure changed, but, when I was, I tested v5.0.0 with both the
optionsand using theLoaderOptionsPlugin(which I know you said doesn't work intentionally) and using justoptionsfailed as well iirc.jhnns commentedon Feb 13, 2017
Ok, now I can reproduce this error on Windows (doesn't happen on macOS):
It seems like node-sass is exporting source maps with forward slashes (which are also valid on Windows). Webpack's source map module, however, stores backslash paths. That's why the source maps can not be resolved.
I can fix this in sass-loader by applying
path.normalizeon all source map paths.Next time, please always post the actual error message including the stack trace.
6 remaining items
asolopovas commentedon Feb 23, 2017
Still does not work on my machine.
Here is my webpack config just in case
And my dependencies
jhnns commentedon Feb 23, 2017
@asolopovas Running your example repo and
--config webpack.config.error.jswith sass-loader6.0.2does not produce any errors:asolopovas commentedon Feb 23, 2017
@jhnns I have updated my sass-loader-test and it confirms that something is not right, the problem seems to be with vue-loader or sass-loader as they don't seem to work together. If I import 'foundation' via app.js file things work fine, if I do import foundation from withing vue component things begin to break down. But most recent vue-loader still works fine with [email protected] and LoaderOptionsPlugin with the same setup where I
@import 'foundation'from within component.jhnns commentedon Feb 24, 2017
I don't know what the vue-loader is doing, but if I remove the sass-loader and just try to compile
App.vuethe same error is still there. So this is not related to the sass-loader.jhnns commentedon Feb 24, 2017
The sass-loader has its own loader pipeline. This configuration fixed the issue:
asolopovas commentedon Feb 24, 2017
A hack solution is definitely better then no solution thanks. Do you think it is the problem with vue-loader?
jhnns commentedon Feb 28, 2017
Oh, I don't think that this is a hack solution. Since a
vuefile can host a lot of file types, it makes sense to have a dedicated loader pipeline because webpack's loadertestalgorithm wouldn't work here.asolopovas commentedon Feb 28, 2017
jhnns commentedon Feb 28, 2017
If you have a
.babelrcor atsconfig.jsoninside your root folder, they are reading the config from these files. But this is loader specific since the tools behind these loaders (babel and typescript) have the same style of configuration. It doesn't apply to all loaders.jhnns commentedon Mar 2, 2017
This is my config and it's working with your sass-loader-test repository
asolopovas commentedon Mar 2, 2017
@jhnns Thank you a lot for this library, and your support. I understand your point, I think that vue-loader with their custom pipeline could added a feature that if no additional setting provided into the pipeline, vue-loader could use default options from sass loader config, that would be definitely convenient.
asolopovas commentedon Mar 2, 2017
@jhnns disregard my previous comment, I did a mistake on my end so I deleted that comment everything works as you said.
jhnns commentedon Mar 2, 2017
No problem. You're welcome :)
I'm willing to help if the other side is providing a test repository. This makes spotting bugs/wrong configurations a lot easier.
a-m-dev commentedon Aug 7, 2018
hey guys , i found a new way for importing slick and slick.scss it is so simple:
(1) just go inside of your
node_modulesfolder and findslick-carouselfolder(2) inside of that find
slick.scssandslick-theme.scssfrom slick folder and open them up(3) create two seperate files with names of
_slick.scssand_slickTheme.scssinside of your style folders of your project(4) copy all from
slick.scssandslick-theme.scssand put them in your newly created files (_slick.scssand_slickTheme.scss)(5) import them in your
app.scssfile(6) now if you are using webpack like me , i'm guessing that you getting can't resolve
'./ajax-loader.gif'error and a cant resolve font error after that(7) in fact those files is been used by
slick-carouselcss it self and for that we can just simple go inside your newly created_slickTheme.scssand find these lines(8) comment them out ,
(9) enjoy it ....