Registry / devops / rename-webpack-plugin

rename-webpack-plugin

JSON →
library2.0.0jsnpmunverified

Webpack plugin for renaming output files, allowing partial filename overrides when using hash-based naming (e.g., [chunkhash]). Version 2.0.0 adds webpack 4 support. Primarily useful for customizing chunk or asset names that webpack's built-in naming can't handle. Lightweight, no extra dependencies beyond webpack peer dependency.

npm install rename-webpack-plugin
INSTALL
IMPORT
SIG · RENAME-WEBPACK-PLU
R
rename-webpack-plugin
devopsjavascriptv2.0.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.

RenameWebpackPlugin
const RenameWebpackPlugin = require('rename-webpack-plugin')
import RenameWebpackPlugin from 'rename-webpack-plugin'
Package uses CommonJS; no default ESM export exists. Use require() or configure bundler for CJS interop.

Shows minimal webpack configuration using rename-webpack-plugin to rename files matching a pattern (e.g., thirdpart.*.js to thirdpart.js).

const RenameWebpackPlugin = require('rename-webpack-plugin'); module.exports = { entry: 'app.js', output: { path: __dirname + '/dist', filename: 'app.[chunkhash].js' }, plugins: [ new RenameWebpackPlugin({ originNameReg: /(.*)thirdpart\..*\.js/, targetName: '$1thirdpart.js' }) ] };
Debug
Known issues
breakingVersion 2.0.0 drops support for webpack <4. If upgrading from v1, ensure your project uses webpack 4+.
fix
Upgrade webpack to ^4.0.0 or stay on rename-webpack-plugin v1.
affects: >=2.0.0
deprecatedCommonJS pattern required; no ESM named export available.
fix
Use require() or use bundler that handles CJS interop (e.g., webpack or babel).
affects: >=2.0.0
gotchaoriginNameReg must be a RegExp object; passing a string will not work and will throw or silently fail.
fix
Always use a RegExp literal: /pattern/ or new RegExp('pattern').
affects: *
gotchatargetName uses String.replace semantics; ensure backreferences like $1 are escaped properly in strings.
fix
Use single quotes or double backslashes: '$1.js' or "$1.js".
affects: *
Errors
Common errors & fixes
TypeError: originNameReg.test is not a function
originNameReg is not a RegExp (e.g., a string was passed).
fix
Ensure originNameReg is a RegExp object (e.g., /pattern/).
Error: Cannot find module 'rename-webpack-plugin'
Package not installed or not in node_modules.
fix
Run 'npm install --save-dev rename-webpack-plugin' or 'yarn add --dev rename-webpack-plugin'.
Module parse failed: Unexpected token (1:0) - You may need an appropriate loader to handle this file type.
Using ES import syntax (import) with a package that only exports CommonJS.
fix
Use require() or enable bundler's CommonJS interop (e.g., webpack's module.rules).
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency required for plugin to function
Agent activity
6 hits · last 30 days
node
6
Resources
rename-webpack-plugin — npm install rename-webpack-plugin · libregistry