Registry / devops / replacer-contenthash-webpack-plugin

replacer-contenthash-webpack-plugin

JSON →
library1.0.17jsnpmunverified

A webpack plugin that replaces references to static files (CSS, JS, images, SVG sprites) in HTML templates and source files with their contenthash-based filenames. Current stable version is 1.0.17 (last updated August 2017). It requires the loader-utils package and works with webpack 3.x and older. Unlike webpack's built-in [contenthash] support, this plugin directly modifies text files (not just output filenames) and is useful for projects that need to update hardcoded paths in templates or source code. It is considered legacy; modern webpack versions (4+) have native similar functionality.

npm install replacer-contenthash-webpack-plugin
INSTALL
IMPORT
SIG · REPLACER-CONTENTHA
R
replacer-contenthash-webpack-plugin
devopsjavascriptv1.0.17
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

default
✓ const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');
✗ import ReplacerContenthashWebpackPlugin from 'replacer-contenthash-webpack-plugin';
Package is CommonJS-only; ESM import will fail.
ReplacerContenthashWebpackPlugin
✓ const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');
✗ const { ReplacerContenthashWebpackPlugin } = require('replacer-contenthash-webpack-plugin');
It is a default export, not a named export.
WebpackPluginInstance
✓ new ReplacerContenthashWebpackPlugin({ filesDir: ['src'] })
✗ ReplacerContenthashWebpackPlugin({ filesDir: ['src'] })
Must be instantiated with new keyword.

Basic webpack config showing plugin instantiation with filesDir and templatesFolder options.

const path = require('path'); const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: '[name].js', publicPath: '/static/' }, plugins: [ new ReplacerContenthashWebpackPlugin({ filesDir: ['src'], templatesFolder: ['templates'] }) ] };
Debug
Known issues
deprecatedPackage is unmaintained since 2017; not compatible with webpack 4+ or webpack 5.
fix
Use webpack's built-in [contenthash] or a maintained alternative like gulp-rev.
affects: >=1.0.0
breakingPlugin requires the 'loader-utils' package as a peer dependency. Missing it will cause runtime errors.
fix
Run: npm install loader-utils --save-dev
affects: >=1.0.0
gotchaThe plugin modifies files in-place; ensure you have backups or version control.
fix
Only run plugin on copies of files or ensure you can revert changes.
affects: >=1.0.0
gotchafiles and templates options expect comma-separated strings for multiple files, not arrays. Example: 'file1.js, file2.js'
fix
Pass a single string with comma-separated paths for each property.
affects: >=1.0.0
deprecatedNo security updates; potential vulnerabilities in dependencies (loader-utils, webpack 3).
fix
Migrate to a modern alternative like webpack-subresource-integrity or html-webpack-plugin with hash.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'loader-utils'
Missing required peer dependency loader-utils.
fix
npm install loader-utils --save-dev
TypeError: ReplacerContenthashWebpackPlugin is not a constructor
Using ESM import or destructured require; package is CommonJS default export.
fix
Use: const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');
Error: Cannot read property 'replace' of undefined
Options filesDir or templatesFolder not set or empty array.
fix
Ensure at least one of filesDir or files is provided, and one of templatesFolder or templates.
Error: Invalid configuration object. webpack has been initialised using a configuration object that does not match the API schema.
Plugin is not compatible with webpack 4+ configuration schema.
fix
Use webpack 3.x or switch to a modern plugin.
Upgrade
Version history
1.0.17latest on npm
Audit
Dependencies
loader-utilsrequiredRequired for hash generation and file path utilities
webpackrequiredPeer dependency; works with webpack 3.x and below
Agent activity
6 hits · last 30 days
node
6
Resources
replacer-contenthash-webpack-plugin — npm install replacer-contenthash-webpack-plugin · libregistry