1.安装依赖
vue2+webpack4
npm install --save-dev stylelint@14 stylelint-config-standard-scss@6 stylelint-config-standard-vue stylelint-order postcss-html postcss-scss stylelint-config-recess-order@3
vue3
npm install --save-dev stylelint stylelint-config-standard-scss stylelint-config-standard-vue stylelint-order postcss-html postcss-scss stylelint-config-recess-order
2. 配置规则
在项目根目录新建文件.stylelintrc.js
,并输入以下内容:
module.exports = {
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-standard-vue/scss",
"stylelint-config-recess-order"
],
"plugins": ["stylelint-order"],
"rules": {}
}
3.开启插件
vscode安装stylelint插件,并设置vscode:
"stylelint.validate": ["css", "less", "postcss", "scss", "html", "vue"]
正文完