解决Stylelint --fix后会把vue文件中css以外的部分删除掉

问题:–fix自动修复会把Vue文件中所有内容都移除掉,只剩css代码
解决方案:移除配置中的processors项
原因: 网上一些过时的教程包括 github 上的讨论都推荐使用 stylelint-processor-html 或者 @mapbox/stylelint-processor-arbitrary-tags 来解析 html 或 vue 中的 css ,这本身并没有什么问题,但是这个插件有个 bug ,当指定 stylelint 的 --fix 后将会把 vue 文件中 以外的部分删掉。

//.stylelintrc
{
  "extends": ["stylelint-config-standard"],
  "plugins": ["stylelint-order"],
  "rules": {
    "order/order": [
        "custom-properties",
        "declarations"
    ],
    "order/properties-alphabetical-order": true,
    "no-empty-source": null,
  }
}


//package.json
"scripts": {
    "lint:css": "stylelint **/*.{vue,css,sass,scss}  --fix",
    "build": "node build/build.js"
  },
发布了10 篇原创文章 · 获赞 0 · 访问量 1583

猜你喜欢

转载自blog.csdn.net/weixin_45266779/article/details/99965154