npm install --save-dev inject-webpack-plugin-head
yarn add --dev inject-webpack-plugin-head
webpack.config.babel.js
import HtmlWebpackPlugin from "html-webpack-plugin"
import InjectHeadPlugin from "inject-webpack-plugin-head"
export default {
plugins: [
new HtmlWebpackPlugin({
templateContent: "<html><head></head></html>"
}),
new InjectHeadPlugin({
content: '<main id=root>Hi!</main>'
}),
],
}
index.html
<html><head><main id=root>Hi!</main></head></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 head 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-webpack-plugin-head
Setting up:
git clone git@github.com:Emiyaa/inject-webpack-plugin-head.git
cd inject-webpack-plugin-head
npm install
Testing in production environment:
# 打包
npm run build
# 发包
npm publish
# 删除发错包
npm unpublish inject-webpack-plugin-head@0.0.5 --force