Webpack plugin (v0.1.17) that detects unused files and unused exports in used files during the webpack build process. It outputs warnings to the terminal without failing the build unless configured otherwise. Works with webpack 3, 4, and 5 via peer dependency. Key differentiators: supports both file and export detection, integrates with TypeScript loaders (with caveats), offers granular logging and JSON export. Active development with periodic releases.
npm install webpack-deadcode-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack config with deadcode plugin to detect unused files/exports.
In .babelrc: { "presets": [["env", { "modules": false }]] } or in webpack config: { loader: 'babel-loader', options: { presets: [['env', { modules: false }]] } }Disable transpileOnly or switch to awesome-typescript-loader for production.
Upgrade to v0.1.13 or later for webpack 5 compatibility.
Add failOnHint: true to options if you want the build to error out.
npm install webpack-deadcode-plugin --save-dev
Use: const DeadCodePlugin = require('webpack-deadcode-plugin'); new DeadCodePlugin(options);Ensure patterns match your source files, e.g., patterns: ['src/**/*.(js|jsx|ts|tsx|css)']
Set modules: false in babel presets as described in documentation.