lint-vue-files-with-stylelint

For the record, this is working configuration for webpack:

1.Install:

1
npm i --save-dev stylelint stylelint-processor-html stylelint-config-standard stylelint-webpack-plugin

2.Create .stylelintrc

1
2
3
4
{
"processors": ["stylelint-processor-html"],
"extends": "stylelint-config-standard"
}

3.Load stylelint-webpack-plugin (in build/webpack.base.conf.js for Vue webpack template)

1
2
3
4
5
6
7
8
9
10
11
12
//...
var StylelintPlugin = require('stylelint-webpack-plugin')

{
//...
plugins: [
//...
new StylelintPlugin({
files: ['**/*.vue']
})
]
}

Add lint:css to package.json

1
2
3
"scripts": {
"lint:css": "stylelint '**/*.vue' --syntax scss"
},

参考

vue-loader

支付宝扫码打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者