Answer the question
In order to leave comments, you need to log in
How to include sass-resources-loader in vue-cli?
Hello, I'm using vue-cli.
I decided to include sass-resources-loader to import variables into the component, but I have no idea how to do it, because no access to webpack config, only vue.config.js.
The documentation suggests merging my settings with cli settings, but no matter how I tried, I couldn't.
Answer the question
In order to leave comments, you need to log in
In general, here is the solution, if someone was also interested. vue.config.js
file
const path = require('path');
module.exports = {
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.tap(options => {
const scssResourceLoader = {
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, 'src/assets/styles/_vars.scss')
}
};
options.loaders.scss.push(scssResourceLoader);
return options;
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question