@plugin-light/webpack-plugin-replace-content
v0.0.4
Published
替换打包产物内容
Downloads
21
Readme
打包内容转换
替换打包产物内容
如何使用
安装
pnpm add @plugin-light/webpack-plugin-replace-content -D
在 vue.config.js
中添加如下设置:
const { ReplaceContentPlugin } = require('@plugin-light/webpack-plugin-replace-content');
const plugins = []
plugins.push(
new ReplaceContentPlugin({
replaceList: [
{
from: new RegExp('background-image:\\s?url\\(https://cdn\\.dcloud\\.net\\.cn/img\\/.*?.png\\);?'),
to: '',
files: [/\.(css|scss|less|wxss)$/],
},
],
})
)
module.exports = {
configureWebpack: {
plugins,
}
}
参数
export type IReplaceList = Array<{
// 要替换的内容
from: string | RegExp;
// 要替换成的目标内容
to: string;
// 要处理的文件列表
files?: Array<string | RegExp>;
}>;
export type IReplaceContentOptions = {
replaceList: IReplaceList;
};