【发布时间】:2020-01-01 10:05:56
【问题描述】:
我想使用 stylelint 正确排除导入的供应商文件。我有这个app.scss:
@import '~bootstrap';
@import '~bootstrap-vue';
body {
background: gray;
}
还有这个.stylelintrc.json:
{
"extends": "stylelint-config-standard"
}
在编译期间(使用 Webpack Encore)我收到超过 8000 个警告,例如:
warning in ./assets/scss/app.scss
Module Warning (from ./node_modules/postcss-loader/src/index.js):
Warning
(9998:1) Expected selector ".input-group-sm > .custom-range" to come before selector ".input-group > .form-control-plaintext + .custom-range" (no-descending-specificity)
我想要的是 0 个警告和 0 个错误。实现这一目标的正确方法是什么?
注意
我已经尝试了很多,例如这个:
/* stylelint-disable */
@import '~bootstrap';
@import '~bootstrap-vue';
/* stylelint-enable */
这样,8000 个警告消失了,但我收到了另一个警告:
(11596:1) Unexpected duplicate selector "body", first used at line 56 (no-duplicate-selectors)
我还尝试通过使用以下选项编辑.stylelintrc.json 来完成我想要的:ignoreFiles、ignorePath、severity、defaultSeverity。我无法让它工作。
【问题讨论】:
-
如何在 webpack 中使用 stylelint?通过 stylelint-webpack-plugin?
-
@felixmosh 是的,确切地说,通过 stylelint-webpack-plugin。这对你有帮助吗?