Registry / devops / inject-body-webpack-plugin

inject-body-webpack-plugin

JSON →
library1.3.0jsnpmunverified

A Webpack plugin (v1.3.0, latest) that injects a custom HTML string into the <body> of html-webpack-plugin output. Released under MIT, updated irregularly. Unlike generic string-replacement plugins, it integrates directly with html-webpack-plugin's compilation hooks, supporting position (start/end) and custom content. Requires html-webpack-plugin ^5.3.1 as a peer dependency. Ships TypeScript types for full IDE support.

npm install inject-body-webpack-plugin
INSTALL
IMPORT
SIG · INJECT-BODY-WEBPAC
I
inject-body-webpack-plugin
devopsjavascriptv1.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InjectBodyPlugin
import InjectBodyPlugin from 'inject-body-webpack-plugin'
import { InjectBodyPlugin } from 'inject-body-webpack-plugin'
Default export only; named import will fail.
InjectBodyPlugin
const InjectBodyPlugin = require('inject-body-webpack-plugin').default
const InjectBodyPlugin = require('inject-body-webpack-plugin')
CJS requires .default because module.exports is an ES module default export.
InjectBodyPlugin
import type { InjectBodyPluginOptions } from 'inject-body-webpack-plugin'
import { InjectBodyPluginOptions } from 'inject-body-webpack-plugin'
Options type is a named export; main class is default export.

Shows basic usage: import the plugin, instantiate with content string, and add to Webpack plugins array alongside HtmlWebpackPlugin.

// webpack.config.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: '<div id="root">App</div>', position: 'start', }), ], };
Debug
Known issues
breakingVersion 1.2.0 removed the 'port' option.
fix
Remove 'port' from options; it is no longer supported.
affects: >=1.2.0
breakingVersion 1.1.0 migrated to html-webpack-plugin 4; incompatible with v3.
fix
Ensure html-webpack-plugin version 4+ is installed.
affects: >=1.1.0
breakingVersion 1.0.0 initial release; default content differs from later versions.
fix
Default content changed in 1.3.0; specify 'content' explicitly for consistent behavior.
affects: >=1.0.0 <1.3.0
gotchaPlugin must be placed after HtmlWebpackPlugin in the plugins array to function correctly.
fix
Order plugins so that HtmlWebpackPlugin appears first.
affects: >=1.0.0
gotchaThe injected content is raw HTML; no escaping. XSS risk if user input is used.
fix
Sanitize any user-provided content before passing to the plugin.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: InjectBodyPlugin is not a constructor
Using named import instead of default import in ESM.
fix
Use `import InjectBodyPlugin from 'inject-body-webpack-plugin'` (no braces).
Cannot find module 'html-webpack-plugin'
Missing peer dependency html-webpack-plugin.
fix
Run `npm install --save-dev html-webpack-plugin`.
Error: Hook 'html-webpack-plugin-before-html-processing' is not supported
Using incompatible html-webpack-plugin version (< 4).
fix
Upgrade html-webpack-plugin to version 4 or higher.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
html-webpack-pluginrequiredpeer dependency required for hooking into HTML generation
Agent activity
4 hits · last 30 days
node
4
Resources
inject-body-webpack-plugin — npm install inject-body-webpack-plugin · libregistry