HtmlReplacePlugin.js 588 字节
Newer Older
B
BingBlog 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
function noopReplace (val) { return val; }

function HtmlReplacePlugin(options) {
    this.replacer = options.replacer || noopReplace;
}

HtmlReplacePlugin.prototype.apply = function(compiler) {

   var replacer = this.replacer;

    compiler.plugin('compilation', function(compilation) {

        compilation.plugin('html-webpack-plugin-after-html-processing', function(htmlPluginData, callback) {

            htmlPluginData.html = replacer(htmlPluginData.html, htmlPluginData);

            callback(null, htmlPluginData);

        });
    });

};

module.exports = HtmlReplacePlugin;