Plugin finds dead code in your project trying compare modules used at Webpack bundle with file system.
Install dependencies
npm istall
Build demo app from ./src/*
npm run build
See generated unused.json
- it will contain potential dead code from your project
Add into your webpack.config.ts
DeadcodePlugin and pass config options:
const config: webpack.Configuration = {
...
plugins: [
new DeadcodePlugin(options),
],
...
}
options is an object of type PluginOptions
:
type PluginOptions = {
outputFile: string, // 'unused.json' by default
rootDir: string // 'src' by default
}