我正在使用Webpack v5.74.0。我想添加一个自定义类到所有CSS规则在构建时使用webpack。.input-text {color: red}应变为.container .input-text {color: red}需要在较少的文件中添加自定义 Package 类。在webpack中找不到任何加载程序来作为此容器类的前缀。请建议。
.input-text {color: red}
.container .input-text {color: red}
pgky5nke1#
try the below code in your webpack to add a wrapper class for all classes present in your project. module: { rules: [ { test: /\.(css|less)$/i, use: [ { loader: "style-loader", }, { loader: "css-loader", }, { loader: "postcss-loader", options: { postcssOptions: { plugins: { "postcss-increase-specificity": { stackableRoot: `.container`, repeat: 1, }, }, }, }, }, { loader: "less-loader", options: { lessOptions: { javascriptEnabled: true, }, }, }, ], }, ], }
1条答案
按热度按时间pgky5nke1#