All Projects → MQuy → Webpack Deadcode Plugin

MQuy / Webpack Deadcode Plugin

Licence: mit
Webpack plugin to detect unused files and unused exports in used files

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webpack Deadcode Plugin

Craco Alias
A craco plugin for automatic aliases generation for Webpack and Jest
Stars: ✭ 56 (-68.89%)
Mutual labels:  webpack, plugin
Fork Ts Checker Webpack Plugin
Webpack plugin that runs typescript type checker on a separate process.
Stars: ✭ 1,343 (+646.11%)
Mutual labels:  webpack, plugin
Serverless Plugin Webpack
Serverless Plugin Webpack
Stars: ✭ 72 (-60%)
Mutual labels:  webpack, plugin
Webpack Alioss Plugin
阿里 oss-webpack 自动上传插件
Stars: ✭ 35 (-80.56%)
Mutual labels:  webpack, plugin
Webpack Plugin Hash Output
Plugin to replace webpack chunkhash with an md5 hash of the final file conent.
Stars: ✭ 128 (-28.89%)
Mutual labels:  webpack, plugin
Dotenv Webpack
A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use.
Stars: ✭ 1,022 (+467.78%)
Mutual labels:  webpack, plugin
Cypress Webpack Preprocessor
Cypress preprocessor for bundling JavaScript via webpack
Stars: ✭ 93 (-48.33%)
Mutual labels:  webpack, plugin
Offline Plugin
Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
Stars: ✭ 4,444 (+2368.89%)
Mutual labels:  webpack, plugin
Webapp Webpack Plugin
[DEPRECATED] use favicons-webpack-plugin instead
Stars: ✭ 127 (-29.44%)
Mutual labels:  webpack, plugin
Sounds Webpack Plugin
🔊Notify or errors, warnings, etc with sounds
Stars: ✭ 125 (-30.56%)
Mutual labels:  webpack, plugin
Feflow
🚀 A command line tool aims to improve front-end engineer workflow and standard, powered by TypeScript.
Stars: ✭ 942 (+423.33%)
Mutual labels:  webpack, plugin
Speed Measure Webpack Plugin
⏱ See how fast (or not) your plugins and loaders are, so you can optimise your builds
Stars: ✭ 1,980 (+1000%)
Mutual labels:  webpack, plugin
Skpm
💎📦 A utility to build and publish Sketch plugins
Stars: ✭ 890 (+394.44%)
Mutual labels:  webpack, plugin
Prepack Webpack Plugin
A webpack plugin for prepack.
Stars: ✭ 1,054 (+485.56%)
Mutual labels:  webpack, plugin
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (+260.56%)
Mutual labels:  webpack, plugin
Award
⚙基于react的服务端渲染框架
Stars: ✭ 91 (-49.44%)
Mutual labels:  webpack, plugin
Serviceworker Webpack Plugin
Simplifies creation of a service worker to serve your webpack bundles. ♻️
Stars: ✭ 454 (+152.22%)
Mutual labels:  webpack, plugin
Webpack Parallel Uglify Plugin
A faster uglifyjs plugin.
Stars: ✭ 456 (+153.33%)
Mutual labels:  webpack, plugin
Wordless
All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
Stars: ✭ 1,374 (+663.33%)
Mutual labels:  webpack, plugin
Webpack Internal Plugin Relation
🔎 a tiny tool to show the relation of webpack internal plugins & hooks
Stars: ✭ 135 (-25%)
Mutual labels:  webpack, plugin

Webpack Deadcode Plugin

Webpack plugin to detect unused files and unused exports in used files

npm node deps licenses

Installation

Via npm:

$ npm install webpack-deadcode-plugin --save-dev

Via yarn:

$ yarn add -D webpack-deadcode-plugin

output

Usage

The 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:

✍️ If you use babel-loader, you have to set modules: false to make it works

# in .babelrc
{
  "presets": [
    ["env", { modules: false }]
  ]
}

# or in webpack.config.js -> module/rules
{
  loader: 'babel-loader',
  options: {
    presets: [
      ['env', { modules: false }]
    ]
  }
}

Webpack 3

const DeadCodePlugin = require('webpack-deadcode-plugin');

const webpackConfig = {
  ...
  plugins: [
    new DeadCodePlugin({
      patterns: [
        'src/**/*.(js|jsx|css)',
      ],
      exclude: [
        '**/*.(stories|spec).(js|jsx)',
      ],
    })
  ]
}

Webpack 4

const DeadCodePlugin = require('webpack-deadcode-plugin');

const webpackConfig = {
  ...
  optimization: {
    usedExports: true,
  },
  plugins: [
    new DeadCodePlugin({
      patterns: [
        'src/**/*.(js|jsx|css)',
      ],
      exclude: [
        '**/*.(stories|spec).(js|jsx)',
      ],
    })
  ]
}

Using non-existent css class names

To detect using non-existent class names in your codebase, you have to use es6-css-loader instead of style-loader/mini-css-extract-plugin. They are quite similiar in term of api except es6-css-loader supports to detect non-existent css class names.

non-existent css class names

You can check samples folder, how to to config webpack-deadcode-plugin and es6-css-loader.

Typescript

Using with typescript loader (ts-loader, awesome-typescript-loader), if you enable transpileOnly/happyPackMode, output might be not correct due to this issue. In case of incorrect output, the workaround solution is disabling transpileOnly, it will slow down webpack compiling time.

✍ Under some circumstances and production mode, if your output displays incorrect unused files, we encourage switching to awesome-typescript-loader.

Configuration

new DeadCodePlugin(options);

options.patterns (default: ["**/*.*"])

The array of patterns to look for unused files and unused export in used files. Directly pass to fast-glob

options.exclude (default: [])

The array of patterns to not look at.

options.context

Current working directoy for patterns above. If you don't set explicitly, your webpack context will be used.

options.failOnHint (default: false)

Deadcode does not interrupt the compilation by default. If you want to cancel the compilation, set it true, it throws a fatal error and stops the compilation.

options.detectUnusedFiles (default: true)

Whether to run unused files detection or not.

options.detectUnusedExport (default: true)

Whether to run unsed export detection or not.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].