vue3.0项目增加less/sass

先安装less less-loader / scss scss-loader / style-loader

1
2
3
4
5
6
yarn add less less-loader style-loader -DEV

or

yarn add scss scss-loader style-loader -DEV

1
vue add style-resources-loader

然后会在根目录下自动建一个vue.config.js

更改一下配置就OK了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const path = require('path')

module.exports = {
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [
path.resolve(__dirname, './src/assets/style/*.less')
]
}
}
}