罗欣大B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
i-tax-management-front-lxzy/build/webpack_plugin.js

30 lines
932 B

function MyWebPackPluginForOne() {
}
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
MyWebPackPluginForOne.prototype.apply = function(compiler) {
compiler.plugin('compilation', function(compilation, options) {
compilation.plugin('html-webpack-plugin-before-html-processing', function(htmlPluginData, callback) {
console.log('---------------------------')
console.log('replace all /static to ./static')
fill(htmlPluginData.assets.css)
fill(htmlPluginData.assets.js)
htmlPluginData.html = htmlPluginData.html.replaceAll("/static", './static')
console.log('---------------------------')
callback(null, htmlPluginData);
});
});
};
function fill(array) {
for (let i = 0; i < array.length; i++) {
array[i] = '.' + array[i]
}
}
module.exports = MyWebPackPluginForOne