1.0.7 • Published 5 years ago

@mokahr/unused-webpack-plugin v1.0.7

Weekly downloads
84
License
MIT
Repository
github
Last release
5 years ago

unused-webpack-plugin

A Webpack plugin used to find unused source files

Usage

  1. Install dependency.

npm install --save-dev @mokahr/unused-webpack-plugin

  1. Update webpack config file.
const UnusedWebpackPlugin = require('@mokahr/unused-webpack-plugin');

// your webpack config
module.exports = {
  ...
  plugins: [
    ...
    new UnusedWebpackPlugin(), // use the 'unused' plugin ;-)
  ]
}
  1. Restart your webpack server and a new file named unused-files will be created under the project working directory.

Configuration

new UnusedWebpackPlugin(options)

optional options.cwd: string

Current working directory, default value is ./

optional options.patterns: string[]

Included glob pattern list, default value is ['**/*.js', '**/*.styl'], which means only .js or .styl files will be checked.

Note: Usually not all the static assets are referenced in js files directly, such as some images or font files, therefore we do not recommend to use the pattern * directly, otherwise you may got some misleading results.

optional options.ignores: string[]

Excluded glob pattern list, default value is ['node_modules/**']

optional options.output: string

The result file path, default value is ./unused-files

Tips

  • Please do not use this plugin on production environment.
  • After generating unused files, you can remove them by shell command cat unused-files | while read LINE; do rm $LINE; done.
1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.0

6 years ago