Enhances html-webpack-plugin functionality by allowing a webpack build to specify a function that alters the generated HTML.
This is an extension plugin for the webpack plugin html-webpack-plugin - a plugin that simplifies the creation of HTML files to serve your webpack bundles.
You must be running webpack on node 6.x or higher
Install the plugin with npm:
$ npm install --save-dev html-webpack-alter-html-plugin
Require the plugin in your webpack config:
var HtmlWebpackAlterHtmlPlugin = require('html-webpack-alter-html-plugin');
Add the plugin to your webpack config as follows:
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackAlterHtmlPlugin(alterHTML)
]
alterHTML
is a function that will be called during build with the HTML file generated by html-webpack-plugin. You can alter the HTML in the function and return the updated string. For example:
function alterHTML(html) {
var $ = cheerio.load(html, {
decodeEntities: false
});
// Alter the HTML.
return $.html();
}
This plugin is based on html-webpack-harddisk-plugin.
Copyright (c) 2017 PointSource, LLC. MIT Licensed.