引用:https://blog.csdn.net/RR_chen/article/details/124389185
https://cli.vuejs.org/zh/guide/css.html
vue-cli全局引入less:
安装 yarn add style-resources-loader --dev
配置vue.config.js
:
java
const path = require('path');
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
},
}
function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, './src/assets/less/import.less'),
],
})
}
```