$ npm install html-append-plugin -D
The plugin will append content to html files duration compilation
var HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlAppendPlugin = require('html-append-plugin');
var webpackConfig = {
entry: 'index.js',
output: {
path: 'dist',
filename: 'bundle.js'
},
plugins: [
new HtmlWebpackPlugin(),
new htmlAppendPlugin({
append: 'added content'
// or
// append: function(){
// return 'added content';
// }
})
]
}
This will generate a file dist/index.html
containing the following content:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Webpack App</title>
</head>
<body>
<script src="bundle.js"></script>
added content
</body>
</html>
MIT © fengzilong