1.npm i change-prefix-loader postcss-change-css-prefix -D 2.在vue.config.js中添加如下代码
config.module
.rule('change-prefix')
.test(/\.js$/)
.include.add(path.resolve(__dirname, './node_modules/element-ui/lib'))
.end()
.use('change-prefix')
.loader('change-prefix-loader')
.options({
prefix: 'el-',
replace: 'portal-'
})
.end()
3.新建postcss.config.js文件
const addCssPrefix = require('postcss-change-css-prefix')
module.exports = {
plugins: [
addCssPrefix({
prefix: 'el-',
replace: 'portal-',
}),
],
}
原文来自:乾坤(微前端)父子样式隔离终极解决方案——替换插件前缀
推荐文章
发表评论