hm-react-cli
Version:
Create a Huimei React project by module
16 lines (14 loc) • 651 B
JavaScript
function ReplaceHtmlPlugin(env) {
this.env = env
}
ReplaceHtmlPlugin.prototype.apply = function(compiler) {
compiler.hooks.compilation.tap('ReplaceHtmlPlugin', (compilation) => {
compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tap('ReplaceHtmlPlugin', (htmlPluginData, callback) => {
let html = htmlPluginData.html;
htmlPluginData.html = html.replace('<!-- replaceHtml -->', `<script src="../Dll.js"></script>`);
// 注入webpack中externals中配置的库,这里暂时只有vue和vueRouter
// callback(null, htmlPluginData)
});
});
}
module.exports = ReplaceHtmlPlugin