# write-file-webpack-plugin

> Forces webpack-dev-server to write bundle files to the file system.

Latest version **4.5.1** (published 2019-07-29) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install write-file-webpack-plugin
pnpm add write-file-webpack-plugin
yarn add write-file-webpack-plugin
bun add write-file-webpack-plugin
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.5.1 |
| Published | 2019-07-29 |
| First published | 2015-10-27 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/write-file-webpack-plugin) |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 7 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 520 |
| Author | Gajus Kuizinas |
| Maintainers | gajus |
| Keywords | webpack, plugin, webpack-dev-server, write, file |

## Links

- npm: https://www.npmjs.com/package/write-file-webpack-plugin
- Repository: https://github.com/gajus/write-file-webpack-plugin
- Homepage: https://github.com/gajus/write-file-webpack-plugin#readme
- Issues: https://github.com/gajus/write-file-webpack-plugin/issues
- npm.io page: https://npm.io/package/write-file-webpack-plugin

## Dependencies (7)

- [chalk](https://npm.io/package/chalk.md) ^2.4.0
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.13
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [moment](https://npm.io/package/moment.md) ^2.22.1
- [filesize](https://npm.io/package/filesize.md) ^3.6.1
- [write-file-atomic](https://npm.io/package/write-file-atomic.md) ^2.3.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 4.5.1 (latest) — 2019-07-29
- 4.5.0 — 2018-11-17
- 4.4.1 — 2018-09-27
- 4.4.0 — 2018-09-05
- 4.3.2 — 2018-05-19
- 4.3.1 — 2018-05-14
- 4.3.0 — 2018-05-14
- 4.2.0 — 2017-09-26
- 4.1.0 — 2017-06-07
- 4.0.2 — 2017-04-15
- 4.0.0 — 2017-03-10
- 3.4.2 — 2016-11-08
- 3.4.1 — 2016-11-02
- 3.4.0 — 2016-11-02
- 3.3.0 — 2016-09-09
- … 15 more at https://npm.io/package/write-file-webpack-plugin/versions

## README

# write-file-webpack-plugin

[![NPM version](http://img.shields.io/npm/v/write-file-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/write-file-webpack-plugin)
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)

Forces `webpack-dev-server` program to write bundle files to the file system.

This plugin has no effect when [`webpack`](https://webpack.github.io/docs/usage.html) program
is used instead of [`webpack-dev-server`](https://webpack.github.io/docs/webpack-dev-server.html).

## Install

```sh
npm install write-file-webpack-plugin --save-dev
```

## API

```js
/**
 * @typedef {Object} options
 * @property {boolean} atomicReplace Atomically replace files content (i.e., to prevent programs like test watchers from seeing partial files) (default: true).
 * @property {boolean} exitOnErrors Stop writing files on webpack errors (default: true).
 * @property {boolean} force Forces the execution of the plugin regardless of being using `webpack-dev-server` or not (default: false).
 * @property {boolean} log Logs names of the files that are being written (or skipped because they have not changed) (default: true).
 * @property {RegExp} test A regular expression used to test if file should be written. When not present, all bundle will be written.
 * @property {boolean} useHashIndex Use hash index to write only files that have changed since the last iteration (default: true).
 */

/**
 * @param {options} options
 * @returns {Object}
 */
new WriteFilePlugin();

new WriteFilePlugin({
    // Write only files that have ".css" extension.
    test: /\.css$/,
    useHashIndex: true
});
```

## Usage

Configure [`webpack.config.js`](https://webpack.github.io/docs/configuration.html) to use the `write-file-webpack-plugin` plugin.

```js
import path from 'path';
import WriteFilePlugin from 'write-file-webpack-plugin';

export default {
    output: {
        path: path.join(__dirname, './dist')
    },
    plugins: [
        new WriteFilePlugin()
    ],
    // ...
}
```

See [./sandbox](./sandbox) for a working `webpack` configuration.

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