{"id":20509,"library":"rename-webpack-plugin","title":"rename-webpack-plugin","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Dcatfly/rename-webpack-plugin","tags":["javascript","plugin","rename","webpack"],"install":[{"cmd":"npm install rename-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add rename-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add rename-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to function","package":"webpack","optional":false}],"imports":[{"note":"Package uses CommonJS; no default ESM export exists. Use require() or configure bundler for CJS interop.","wrong":"import RenameWebpackPlugin from 'rename-webpack-plugin'","symbol":"RenameWebpackPlugin","correct":"const RenameWebpackPlugin = require('rename-webpack-plugin')"}],"quickstart":{"code":"const RenameWebpackPlugin = require('rename-webpack-plugin');\n\nmodule.exports = {\n  entry: 'app.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'app.[chunkhash].js'\n  },\n  plugins: [\n    new RenameWebpackPlugin({\n      originNameReg: /(.*)thirdpart\\..*\\.js/,\n      targetName: '$1thirdpart.js'\n    })\n  ]\n};","lang":"javascript","description":"Shows minimal webpack configuration using rename-webpack-plugin to rename files matching a pattern (e.g., thirdpart.*.js to thirdpart.js)."},"warnings":[{"fix":"Upgrade webpack to ^4.0.0 or stay on rename-webpack-plugin v1.","message":"Version 2.0.0 drops support for webpack <4. If upgrading from v1, ensure your project uses webpack 4+.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use require() or use bundler that handles CJS interop (e.g., webpack or babel).","message":"CommonJS pattern required; no ESM named export available.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Always use a RegExp literal: /pattern/ or new RegExp('pattern').","message":"originNameReg must be a RegExp object; passing a string will not work and will throw or silently fail.","severity":"gotcha","affected_versions":"*"},{"fix":"Use single quotes or double backslashes: '$1.js' or \"$1.js\".","message":"targetName uses String.replace semantics; ensure backreferences like $1 are escaped properly in strings.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure originNameReg is a RegExp object (e.g., /pattern/).","cause":"originNameReg is not a RegExp (e.g., a string was passed).","error":"TypeError: originNameReg.test is not a function"},{"fix":"Run 'npm install --save-dev rename-webpack-plugin' or 'yarn add --dev rename-webpack-plugin'.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'rename-webpack-plugin'"},{"fix":"Use require() or enable bundler's CommonJS interop (e.g., webpack's module.rules).","cause":"Using ES import syntax (import) with a package that only exports CommonJS.","error":"Module parse failed: Unexpected token (1:0) - You may need an appropriate loader to handle this file type."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}