Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.
npm install --save-dev inject-body-webpack-plugin@^1.3.0
yarn add --dev inject-body-webpack-plugin@^1.3.0
webpack.config.babel.js
import HtmlWebpackPlugin from "html-webpack-plugin"
import InjectBodyPlugin from "inject-body-webpack-plugin"
export default {
plugins: [
new HtmlWebpackPlugin({
templateContent: "<html><body></body></html>"
}),
new InjectBodyPlugin({
content: '<main id=root>Hi!</main>'
}),
],
}
index.html
<html><body><main id=root>Hi!</main></body></html>
Type | Default | Info | |
---|---|---|---|
content | string | <div id=root/> | The text that will be injected into the final HTML output. |
position | string | start | If “start”, the content will be injected as close to the body opening tag as possible. If “end”, the content will be injected as close to the body ending tag as possible. |
Development hints for maintaining and improving inject-body-webpack-plugin
Setting up:
git clone [email protected]:jaid/inject-body-webpack-plugin.git
cd inject-body-webpack-plugin
npm install
Testing in production environment:
npm run test
MIT License
Copyright © 2021, Jaid <[email protected]> (https://github.com/jaid)