@contagt/inject-body-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.4.9 • Public • Published

inject-body-webpack-plugin

License Sponsor inject-body-webpack-plugin
Build status Commits since v1.3.0 Last commit Issues
Latest version on npm Dependents Downloads

Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.

Installation

inject-body-webpack-plugin on npm

npm install --save-dev inject-body-webpack-plugin@^1.3.0

inject-body-webpack-plugin on Yarn

yarn add --dev inject-body-webpack-plugin@^1.3.0

Example

Input

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>'
    }),
  ],
}

Output

index.html

<html><body><main id=root>Hi!</main></body></html>

Options

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.
startTag string Defines how the opening tag does look like that the content will be inserted after.
endTag string Defines how the closing tag does look like that the content will be inserted before.

Development

Development hints for maintaining and improving inject-body-webpack-plugin

Setting up:

git clone git@github.com:jaid/inject-body-webpack-plugin.git
cd inject-body-webpack-plugin
npm install

Testing in production environment:

npm run test

License

MIT License
Copyright © 2021, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)

Readme

Keywords

Package Sidebar

Install

npm i @contagt/inject-body-webpack-plugin

Weekly Downloads

2

Version

1.4.9

License

none

Unpacked Size

13.9 kB

Total Files

6

Last publish

Collaborators

  • sbrandt