{"id":19464,"library":"emit-changed-only-webpack-plugin","title":"emit-changed-only-webpack-plugin","description":"Webpack production plugin that prevents identical output files from being re-emitted after a rebuild, preserving cache headers (ETag, Last-Modified) for unchanged assets. Current stable version 2.1.4 requires webpack ^4.0.0. Key differentiator: focuses on file emission behavior rather than chunk-level comparison, using [contenthash] to detect changes. Helps improve browser caching and V8 code caching by avoiding unnecessary file modifications. Ships TypeScript types.","status":"active","version":"2.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/stefvw93/emit-changed-only-webpack-plugin","tags":["javascript","emit","changed","only","plugin","webpack","typescript"],"install":[{"cmd":"npm install emit-changed-only-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add emit-changed-only-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add emit-changed-only-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin integrates with webpack's compiler hooks","package":"webpack","optional":false}],"imports":[{"note":"Package is CommonJS only. ES module import will fail. If TypeScript, use `import EmitChangedOnlyPlugin = require(...)` or set `esModuleInterop`.","wrong":"import EmitChangedOnlyPlugin from 'emit-changed-only-webpack-plugin'","symbol":"EmitChangedOnlyPlugin","correct":"const EmitChangedOnlyPlugin = require('emit-changed-only-webpack-plugin')"},{"note":"Default export only. Named import does not exist.","wrong":"import { EmitChangedOnlyPlugin } from 'emit-changed-only-webpack-plugin'","symbol":"default","correct":"import EmitChangedOnlyPlugin from 'emit-changed-only-webpack-plugin'"},{"note":"Always pass at least an options object; omitting may cause unexpected behavior with default options (e.g., production mode required).","wrong":"new EmitChangedOnlyPlugin()","symbol":"EmitChangedOnlyPlugin","correct":"new EmitChangedOnlyPlugin({ exclude: /\\.html$/i })"}],"quickstart":{"code":"const EmitChangedOnlyPlugin = require('emit-changed-only-webpack-plugin');\n\nmodule.exports = {\n  output: {\n    path: './dist',\n    filename: '[name].[contenthash].js'\n  },\n  plugins: [\n    new EmitChangedOnlyPlugin({\n      exclude: /\\.html$/i\n    })\n  ]\n};","lang":"javascript","description":"Minimal webpack configuration using the plugin with contenthash filenames and an HTML exclusion pattern."},"warnings":[{"fix":"Add [contenthash] to output.filename, e.g., '[name].[contenthash].js'.","message":"Plugin requires [contenthash] in output filename; without it, file comparison is unreliable and plugin may emit all files every build.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set mode: 'production' in webpack config, or pass production: false in plugin options.","message":"Production mode is enforced by default. If mode is not 'production', plugin will skip logic and may not behave as expected.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add patterns to exclude option to protect non-plugin files, e.g., exclude: /\\.(txt|png)$/i.","message":"The plugin removes outdated files in the output directory. Any files that are not produced by webpack and not excluded may be deleted.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you want chunk splitting, keep splitChunks: true (default). Set to false only if you know you don't need it.","message":"Using splitChunks: false will disable chunk splitting optimization; only the entry chunk is emitted. Default is true.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use const EmitChangedOnlyPlugin = require('emit-changed-only-webpack-plugin');","cause":"Importing as ES module named import or using wrong require path.","error":"TypeError: plugin is not a constructor"},{"fix":"npm install emit-changed-only-webpack-plugin --save-dev","cause":"Package not installed or misspelled npm package name.","error":"Cannot find module 'emit-changed-only-webpack-plugin'"},{"fix":"Set mode: 'production' or pass production: false in plugin options.","cause":"Plugin enforces production mode by default.","error":"Error: Webpack mode must be 'production'"},{"fix":"Add [contenthash] to output.filename, e.g., '[name].[contenthash].js'.","cause":"Output filename does not contain [contenthash].","error":"Error: No output filename with [contenthash] found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}