vue-cli3下隐藏了webpack的配置项,需要在目录下新建不饿,vue.config.js去配置
module.exports = {
css: {
loaderOptions: {
sass: {
prependData: `
@import "@/assets/css/common.scss";
`
}
}
}
};
如果是低版本sass-loader,需要使用参数名data
高版本使用data会报错
ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'data'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
module.exports = {
css: {
loaderOptions: {
sass: {
data: `
@import "@/assets/css/common.scss";
`
}
}
}
};