A webpack plugin that detects and lists unused source files in one or more directories, helping developers identify dead code. Current stable version is 2.4.0, with maintenance through minor releases. It supports webpack 3 and 4 via the hooks API. Key differentiators: simple configuration (directories, exclude patterns, root), optional failure on unused files, and respect for .gitignore (default true). It does not remove files, only reports them, and is focused on development builds. Compared to alternatives like 'webpack-deadcode-plugin', it is more minimal and relies on directories rather than webpack's module graph exclusively.
npm install unused-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Shows minimal webpack config with the UnusedWebpackPlugin, scanning 'src' directory, excluding test files, and setting root for relative output.
Upgrade to webpack 4+ or use v1.2.0 for webpack 3 support.
Consider alternatives like webpack-deadcode-plugin or unimported.
Use tools like ESLint with no-unused-vars or webpack-deadcode-plugin for unused exports.
Always use path.join(__dirname, 'dir') or path.resolve() to define directories.
Run 'npm install webpack' or ensure webpack is in your devDependencies.
Use 'const UnusedWebpackPlugin = require('unused-webpack-plugin');' (no destructuring).Check that 'directories' array includes every source folder and adjust 'exclude' patterns (e.g., remove 'node_modules/**' if already ignored).