I'm trying to configure vue-loader to make it include node_modules in @import
statements.
The loader config for scss files that works fine looks like this:
{
test: /\.(sass|scss)$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
includePaths: [path.resolve(__dirname, 'node_modules')],
},
},
],
},
So now I'm trying to get this working inside .vue files. I thought of something like this:
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// ?{"includePaths":["C:/Users/samuel/Code/school/tinf/sem03/proj01/node_modules"]}
sass: 'vue-style-loader!css-loader!sass-loader?' +
`includePaths[]=${path.resolve(__dirname, 'node_modules').replace(/\\/g, '/')}`,
},
},
},
I get an error message:
ERROR in ./~/css-loader!./~/vue-loader/lib/style-rewriter.js?id=data-v-1ec85c08!./~/sass-loader?includePaths[]=C:/Users/samuel/Code/school/tinf/sem03/proj01/node_modules!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/PageHeader.vue
I've tried removing vue-style-loader
and css-loader
from the stack, and I still get an error.
But when I directly pass the options into the style tag, it works fine:
<style lang="sass?{"includePaths":["C:/Users/samuel/Code/school/tinf/sem03/proj01/node_modules"]}">
How do I have to modify the loaders to make it work?