{"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,"search_vec":"'1.0.17':35 '2017':39 '3':51 '4':96 'august':38 'base':29 'built':59 'built-in':58 'code':88 'consid':91 'contenthash':2,28,61,102 'contenthash-bas':27 'css':14 'current':31 'direct':65 'file':13,24,68 'filenam':30,72 'function':100 'hardcod':82 'html':20 'imag':16 'javascript':101 'js':15 'last':36 'legaci':92 'loader':44 'loader-util':43 'modern':93 'modifi':66 'nativ':98 'need':79 'older':54 'output':71 'packag':46 'path':83 'plugin':4,7,64,104 'project':77 'refer':10 'replac':1,9 'requir':41 'similar':99 'sourc':23,87 'sprite':18 'stabl':32 'static':12 'support':62 'svg':17 'templat':21,85 'text':67 'unlik':55 'updat':37,81 'use':75 'util':45 'version':33,95 'webpack':3,6,50,56,94,103 'work':48 'x':52","created_at":"2026-04-25T11:23:31.102298+00:00","updated_at":"2026-04-25T11:23:31.102298+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/replacer-contenthash-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}