UNPKG

1.27 kBMarkdownView Raw
1## Webpack Deadcode Plugin
2
3Webpack plugin to detect unused files and unused exports in used files
4
5### Installation
6
7Via npm:
8
9```
10$ npm install webpack-deadcode-plugin --save-dev
11```
12
13Via yarn:
14
15```
16$ yarn add -D webpack-deadcode-plugin
17```
18
19### Usage
20
21The plugin will report unused files and unused exports into your terminal but those are not part of your webpack build process, therefore, it will not fail your build (warning you). Simple add into your webpack config as follows:
22
23```
24const DeadCodePlugin = require('webpack-deadcode-plugin);
25
26const webpackConfig = {
27 ...
28 plugins: [
29 new DeadCodePlugin({
30 patterns: [
31 'src/**/*.(js|jsx|css)',
32 ],
33 exclude: [
34 '**/*.(stories|spec).(js|jsx)',
35 ],
36 })
37 ]
38}
39```
40
41### Configuration
42
43```
44new DeadCodePlugin(options)
45```
46
47#### options.patterns
48
49The array of patterns to look for unused files and unused export in used files.
50
51+ Default: `["**/*.*"]`
52+ Directly pass to `[fast-glob](https://github.com/mrmlnc/fast-glob)`
53
54#### options.exclude
55
56The array of patterns to not look at.
57
58#### options.context
59
60Current working directoy for patterns above. If you don't set explicitly, your webpack context will be used.
\No newline at end of file