npm添加less less-loader sass-resources-loader
修改nuxt.config.js
build: {
extend(config, ctx) {
const sassResourcesLoader = {
loader: 'sass-resources-loader',
options: {
resources: ['assets/style/theme.less', 'assets/style/mixins.less']
}
}
config.module.rules.forEach(rule => {
if (rule.test.toString() === '/\\.vue$/') {
rule.options.loaders.less.push(sassResourcesLoader)
}
if (rule.test.toString() === '/\\.less$/') {
rule.use.push(sassResourcesLoader)
}
})
}
}