# emit-changed-only-webpack-plugin

> Webpack plugin to only emit changed files.

Latest version **2.1.4** (published 2020-02-07) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install emit-changed-only-webpack-plugin
pnpm add emit-changed-only-webpack-plugin
yarn add emit-changed-only-webpack-plugin
bun add emit-changed-only-webpack-plugin
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.4 |
| Published | 2020-02-07 |
| First published | 2019-09-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stef van Wijchen |
| Maintainers | stefvw93 |
| Keywords | emit, changed, only, plugin, webpack |

## Links

- npm: https://www.npmjs.com/package/emit-changed-only-webpack-plugin
- Repository: https://github.com/stefvw93/emit-changed-only-webpack-plugin
- Homepage: https://github.com/stefvw93/emit-changed-only-webpack-plugin#readme
- Issues: https://github.com/stefvw93/emit-changed-only-webpack-plugin/issues
- npm.io page: https://npm.io/package/emit-changed-only-webpack-plugin

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 2.1.4 (latest) — 2020-02-07
- 2.1.3 — 2019-11-21
- 2.1.1 — 2019-09-24
- 2.1.0 — 2019-09-24
- 2.0.6 — 2019-09-19
- 2.0.5 — 2019-09-19
- 2.0.4 — 2019-09-19
- 2.0.3 — 2019-09-19
- 2.0.2 — 2019-09-19
- 2.0.1 — 2019-09-19
- 2.0.0 — 2019-09-19
- 1.3.1 — 2019-09-19
- 1.3.0 — 2019-09-19
- 1.2.4 — 2019-09-19
- 1.2.3 — 2019-09-19
- … 15 more at https://npm.io/package/emit-changed-only-webpack-plugin/versions

## README

# emit-changed-only-webpack-plugin

Webpack production plugin to only emit changed files.

Why?

When your app bundle is overwritten - even when maintaining the same file name - the server might see the file is changed (e.g. by modified date). A client browser will request the file and the server will tell the browser that the file changed. Which results in the browser downloading, interpreting and compiling your JS, every time the app is started.

See https://v8.dev/blog/code-caching-for-devs.

Using this plugin, identical files won't be modified: No new date, no new ETag, so your app will be browser cache friendly. This will grant your web app faster load times and less data usage.

🔥

## Usage

### Install the plugin

```bash
npm i -D emit-changed-only-plugin
```

### Use the plugin

Important! Use the webpack substitute `[contenthash]` in your filename. This is used to compare file versions.

```javascript
// webpack.production.js

const EmitChangedOnlyPlugin = require("emit-changed-only-webpack-plugin");

module.exports = {
  // ... webpack config

  output: {
    path: "./dist",
    /**
     * Use a hashed webpack substitute to generate a filename.
     * [contenthash] is recommended because the hash represents file contents.
     */
    filename: "[name].[contenthash].js"
  },
  plugins: [
    new EmitChangedOnlyPlugin({
      exclude: /\.html/i
    })
  ]
};
```

### Settings

You can pass some settings, but this should generally not be necessary.

|Name|Type|Description|Default
|-|-|-|-|
|alwaysOverwrite|string \| RegExp|Matches will alway be emitted|undefined
|exclude|string \| RegExp|The plugin won't do anything to the matched filenames|undefined
|production|boolean|Require webpack production mode|true
|splitChunks|boolean|Use chunk splitting (recommended)|true
|test|string \| RegExp|Apply the plugin to matched filenames|/\\.js/i

## Note

The plugin will attempt to keep your distribution directory clean, by removing outdated, previously built files. So you won't have to - and should not - clear your distribution directory. To keep certain files from being deleted, you can add them to the `exclude` setting.

---
_Source: https://npm.io/package/emit-changed-only-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
