Registry / devops / replace-webpack-plugin

replace-webpack-plugin

JSON →
library0.1.2jsnpmunverified

A Webpack plugin to replace content blocks in HTML files using comment markers. Version 0.1.2 is the latest stable release, with no further updates since 2017. It allows replacing named blocks (`<!-- replace:name --> ... <!-- endreplace -->`) with provided strings, and also supports replacing a placeholder with the Webpack entry hash. Intended for simple HTML injection during builds, but it is a very old plugin with known limitations: it does not support Webpack 4+ or async operations, and the GitHub repository is archived. For modern projects, consider `html-webpack-plugin` with its template features instead.

npm install replace-webpack-plugin
INSTALL
IMPORT
SIG · REPLACE-WEBPACK-PL
R
replace-webpack-plugin
devopsjavascriptv0.1.2
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.

ReplacePlugin
const ReplacePlugin = require('replace-webpack-plugin');
import ReplacePlugin from 'replace-webpack-plugin';
The package v0.1.2 only supports CommonJS require, not ES modules.
default
const ReplacePlugin = require('replace-webpack-plugin');
const { ReplacePlugin } = require('replace-webpack-plugin');
The exported object is the constructor itself; destructuring will yield undefined.
ReplacePlugin
new ReplacePlugin({...})
new ReplacePlugin.default({...})
No .default property; direct instantiation of the required object works.

Configures ReplacePlugin in a Webpack 3 build to replace CSS and JS blocks in index.html and substitute [hash] placeholder.

// webpack.config.js const ReplacePlugin = require('replace-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: './build', filename: 'bundle.js' }, plugins: [ new ReplacePlugin({ skip: false, entry: 'index.html', hash: '[hash]', output: '/build/index.html', data: { css: '<link rel="stylesheet" href="styles.css">', js: '<script src="bundle.js"></script>' } }) ] };
Debug
Known issues
deprecatedPackage is unmaintained since 2017 and does not support Webpack 4+ or async hooks.
fix
Migrate to html-webpack-plugin with custom templates or use a modern replacement like @dexbyte/replace-webpack-plugin.
affects: >=0.1.2
gotchaThe `skip` option must be a Boolean; any truthy value (e.g., 'false' string) will skip replacement.
fix
Use Boolean check: skip: process.env.NODE_ENV === 'development'.
affects: *
breakingPlugin uses synchronous file operations; it will fail if the entry file does not exist at build time.
fix
Ensure the entry file path is correct relative to the webpack context.
affects: *
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'replace-webpack-plugin'
Package not installed or npm install failed.
fix
Run: npm install replace-webpack-plugin --save-dev
Cannot read property 'options' of undefined
Plugin instantiated without new keyword or imported incorrectly.
fix
Use: const ReplacePlugin = require('replace-webpack-plugin'); new ReplacePlugin({...})
webpack: TypeError: plugin.apply is not a function
Using an older version of the plugin with Webpack 4+ that no longer supports old plugin API.
fix
Downgrade to webpack 3 or upgrade to a compatible replacement.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
replace-webpack-plugin — npm install replace-webpack-plugin · libregistry