{"id":20511,"library":"replace-webpack-plugin","title":"replace-webpack-plugin","description":"A Webpack plugin to replace content blocks in HTML files using comment markers. Version 0.1.2 is the latest stable release, with no further updates since 2017. It allows replacing named blocks (`<!-- replace:name --> ... <!-- endreplace -->`) with provided strings, and also supports replacing a placeholder with the Webpack entry hash. Intended for simple HTML injection during builds, but it is a very old plugin with known limitations: it does not support Webpack 4+ or async operations, and the GitHub repository is archived. For modern projects, consider `html-webpack-plugin` with its template features instead.","status":"deprecated","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/otelnov/replace-webpack-plugin","tags":["javascript","replace","webpack","html","gulp-html-replace","webpack hash","hash","otelnov"],"install":[{"cmd":"npm install replace-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add replace-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add replace-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package v0.1.2 only supports CommonJS require, not ES modules.","wrong":"import ReplacePlugin from 'replace-webpack-plugin';","symbol":"ReplacePlugin","correct":"const ReplacePlugin = require('replace-webpack-plugin');"},{"note":"The exported object is the constructor itself; destructuring will yield undefined.","wrong":"const { ReplacePlugin } = require('replace-webpack-plugin');","symbol":"default","correct":"const ReplacePlugin = require('replace-webpack-plugin');"},{"note":"No .default property; direct instantiation of the required object works.","wrong":"new ReplacePlugin.default({...})","symbol":"ReplacePlugin","correct":"new ReplacePlugin({...})"}],"quickstart":{"code":"// webpack.config.js\nconst ReplacePlugin = require('replace-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: './build',\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new ReplacePlugin({\n      skip: false,\n      entry: 'index.html',\n      hash: '[hash]',\n      output: '/build/index.html',\n      data: {\n        css: '<link rel=\"stylesheet\" href=\"styles.css\">',\n        js: '<script src=\"bundle.js\"></script>'\n      }\n    })\n  ]\n};","lang":"javascript","description":"Configures ReplacePlugin in a Webpack 3 build to replace CSS and JS blocks in index.html and substitute [hash] placeholder."},"warnings":[{"fix":"Migrate to html-webpack-plugin with custom templates or use a modern replacement like @dexbyte/replace-webpack-plugin.","message":"Package is unmaintained since 2017 and does not support Webpack 4+ or async hooks.","severity":"deprecated","affected_versions":">=0.1.2"},{"fix":"Use Boolean check: skip: process.env.NODE_ENV === 'development'.","message":"The `skip` option must be a Boolean; any truthy value (e.g., 'false' string) will skip replacement.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure the entry file path is correct relative to the webpack context.","message":"Plugin uses synchronous file operations; it will fail if the entry file does not exist at build time.","severity":"breaking","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install replace-webpack-plugin --save-dev","cause":"Package not installed or npm install failed.","error":"Module not found: Error: Can't resolve 'replace-webpack-plugin'"},{"fix":"Use: const ReplacePlugin = require('replace-webpack-plugin'); new ReplacePlugin({...})","cause":"Plugin instantiated without new keyword or imported incorrectly.","error":"Cannot read property 'options' of undefined"},{"fix":"Downgrade to webpack 3 or upgrade to a compatible replacement.","cause":"Using an older version of the plugin with Webpack 4+ that no longer supports old plugin API.","error":"webpack: TypeError: plugin.apply is not a function","affected_versions":">=0.1.2"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}