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