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.
npm install emit-changed-only-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal webpack configuration using the plugin with contenthash filenames and an HTML exclusion pattern.
Add [contenthash] to output.filename, e.g., '[name].[contenthash].js'.
Set mode: 'production' in webpack config, or pass production: false in plugin options.
Add patterns to exclude option to protect non-plugin files, e.g., exclude: /\.(txt|png)$/i.
If you want chunk splitting, keep splitChunks: true (default). Set to false only if you know you don't need it.
Use const EmitChangedOnlyPlugin = require('emit-changed-only-webpack-plugin');npm install emit-changed-only-webpack-plugin --save-dev
Set mode: 'production' or pass production: false in plugin options.
Add [contenthash] to output.filename, e.g., '[name].[contenthash].js'.