html-webpack-insert-at-body-end
v2.0.0
Published
Allows for the insertion of script tags at the end of the body element after HtmlWebpackPlugin has executed
Downloads
18
Maintainers
Readme
HTML Webpack Insert at Body End Plugin
When using the HtmlWebpackPlugin, it may be necessary to ensure that a script tag is inserted at the end of the HTML body.
If inject: body
is used for injecting chunks, it is impossible to ensure insertion of a non chunk script tag after the chunks.
This webpack plugin captures the HTML produced by HtmlWebpackPlugin and allows for the insertion of a script tag at the end of a body.
Installation
Install the plugin with npm:
$ npm install html-webpack-insert-at-body-end --save-dev
Basic Usage
The plugin will take the HTML5 file generated by the HtmlWebpackPlugin and append a script tag to the body. Just add the plugin to your webpack config as follows:
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackInsertAtBodyEndPlugin = require('html-webpack-insert-at-body-end');
var webpackConfig = {
entry: 'index.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({filename: 'index.html'}),
new HtmlWebpackInsertAtBodyEndPlugin({filename: 'index.html', scriptSrc: 'scripts/patch.js'})
]
};