HTML pre-processing and post-processing for html-webpack-plugin. It supports webpack v4.
npm install html-webpack-processing-plugin
- add pre-processor
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackProcessingPlugin = require("html-webpack-processing-plugin");
const webpackConfig = {
entry: "index.js",
output: {
path: "dist",
filename: "index_bundle.js",
},
plugins: [
new HtmlWebpackPlugin({
preProcessing: (originalHTML) => {
let newHTML = originalHTML + "<div></div>";
return newHTML;
},
}),
new HtmlWebpackProcessingPlugin(),
],
};
- add post-processor
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackProcessingPlugin = require('html-webpack-processing-plugin';)
const webpackConfig = {
entry: 'index.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
postProcessing: originalHTML => {
let newHTML = originalHTML + '<div></div>';
return newHTML;
}
}),
new HtmlWebpackProcessingPlugin()
]
};
This project is licensed under MIT.