{"id":20513,"library":"replacer-contenthash-webpack-plugin","title":"Replacer Contenthash Webpack Plugin","description":"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.","status":"deprecated","version":"1.0.17","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","contenthash","webpack","plugin"],"install":[{"cmd":"npm install replacer-contenthash-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add replacer-contenthash-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add replacer-contenthash-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for hash generation and file path utilities","package":"loader-utils","optional":false},{"reason":"Peer dependency; works with webpack 3.x and below","package":"webpack","optional":false}],"imports":[{"note":"Package is CommonJS-only; ESM import will fail.","wrong":"import ReplacerContenthashWebpackPlugin from 'replacer-contenthash-webpack-plugin';","symbol":"default","correct":"const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');"},{"note":"It is a default export, not a named export.","wrong":"const { ReplacerContenthashWebpackPlugin } = require('replacer-contenthash-webpack-plugin');","symbol":"ReplacerContenthashWebpackPlugin","correct":"const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');"},{"note":"Must be instantiated with new keyword.","wrong":"ReplacerContenthashWebpackPlugin({ filesDir: ['src'] })","symbol":"WebpackPluginInstance","correct":"new ReplacerContenthashWebpackPlugin({ filesDir: ['src'] })"}],"quickstart":{"code":"const path = require('path');\nconst ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: '[name].js',\n    publicPath: '/static/'\n  },\n  plugins: [\n    new ReplacerContenthashWebpackPlugin({\n      filesDir: ['src'],\n      templatesFolder: ['templates']\n    })\n  ]\n};","lang":"javascript","description":"Basic webpack config showing plugin instantiation with filesDir and templatesFolder options."},"warnings":[{"fix":"Use webpack's built-in [contenthash] or a maintained alternative like gulp-rev.","message":"Package is unmaintained since 2017; not compatible with webpack 4+ or webpack 5.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Run: npm install loader-utils --save-dev","message":"Plugin requires the 'loader-utils' package as a peer dependency. Missing it will cause runtime errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Only run plugin on copies of files or ensure you can revert changes.","message":"The plugin modifies files in-place; ensure you have backups or version control.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass a single string with comma-separated paths for each property.","message":"files and templates options expect comma-separated strings for multiple files, not arrays. Example: 'file1.js, file2.js'","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to a modern alternative like webpack-subresource-integrity or html-webpack-plugin with hash.","message":"No security updates; potential vulnerabilities in dependencies (loader-utils, webpack 3).","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install loader-utils --save-dev","cause":"Missing required peer dependency loader-utils.","error":"Module not found: Can't resolve 'loader-utils'"},{"fix":"Use: const ReplacerContenthashWebpackPlugin = require('replacer-contenthash-webpack-plugin');","cause":"Using ESM import or destructured require; package is CommonJS default export.","error":"TypeError: ReplacerContenthashWebpackPlugin is not a constructor"},{"fix":"Ensure at least one of filesDir or files is provided, and one of templatesFolder or templates.","cause":"Options filesDir or templatesFolder not set or empty array.","error":"Error: Cannot read property 'replace' of undefined"},{"fix":"Use webpack 3.x or switch to a modern plugin.","cause":"Plugin is not compatible with webpack 4+ configuration schema.","error":"Error: Invalid configuration object. webpack has been initialised using a configuration object that does not match the API schema."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}