UNPKG

2.02 kBMarkdownView Raw
1# Ignore Emit Webpack plugin
2
3[![Build Status](https://travis-ci.org/mrbar42/ignore-emit-webpack-plugin.svg?branch=master)](https://travis-ci.org/mrbar42/ignore-emit-webpack-plugin)
4
5Prevent files that are matching a pattern from being emitted in a webpack build.
6This is achieved with a webpack plugin.
7
8You can easily ignore file by accident - use with care.
9
10## Quick Usage
11
12```sh
13npm i --save-dev ignore-emit-webpack-plugin
14
15```
16Typescript
17```typescript
18// webpack.config.js
19import IgnoreEmitPlugin from 'ignore-emit-webpack-plugin';
20
21export default {
22 // ...
23 plugins: [
24 new IgnoreEmitPlugin(/\.map$/)
25 ]
26};
27```
28
29JS
30```js
31// webpack.config.js
32const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
33
34module.exports = {
35 // ...
36 plugins: [ new IgnoreEmitPlugin(/\.map$/) ]
37 // ...
38};
39```
40
41The module is written in Node 8.x flavored es6.
42To get the es5 transpiled version use `require('ignore-emit-webpack-plugin/es5')`
43
44## Usage
45
46Signature: `new IgnoreEmitPlugin(patterns, options)`
47
48
49- **patterns** `{RegExp|string|Array.<RegExp|string>}` - regex, string or array with mixed regex/strings (deep nesting allowed),
50to match against the **OUTPUT** path of assets.
51- **options** `{object}` - optional, options object
52 - options.debug `{boolean}` - prints extra logs
53
54not defining patterns or defining invalid pattern will throw error.
55
56```js
57// single regex
58new IgnoreEmitPlugin(/\/artifacy.js$/);
59// single regex in array
60new IgnoreEmitPlugin([ /\/artifacy.js$/ ]);
61// mixed array
62new IgnoreEmitPlugin([ 'file.woff', /\/artifacy.js$/ ]);
63
64// you can also do this - but you really shouldn't
65new IgnoreEmitPlugin([ [ [ [ /\/artifacy.js$/ ] ] ] ]);
66
67
68// file.js
69// dir/file.js
70
71new IgnoreEmitPlugin('file.js'); // both file.js and dir/file.js ignored
72new IgnoreEmitPlugin(/\/file\.js/); // only dir/file.js is ignored
73new IgnoreEmitPlugin(/^file\.js/); // only file.js is ignored
74```
75
76## I want to help!
77
78Contribution would be much appreciated.
79Either by creating pull requests of opening issues.