Webpack Warnings to Errors Plugin

2.3.0 · active · verified Tue Apr 21

The `warnings-to-errors-webpack-plugin` is a utility for Webpack that elevates all build warnings to errors, ensuring a stricter compilation process. This plugin is currently at version 2.3.0 and is actively maintained, primarily releasing updates to ensure compatibility with new major versions of Webpack or to incorporate enhanced filtering capabilities. Its core differentiator is enforcing a zero-warning policy, which is particularly beneficial in continuous integration/continuous deployment (CI/CD) environments where subtle build warnings could otherwise be overlooked, potentially leading to runtime issues. It integrates seamlessly with Webpack's native `warningsFilter` and `ignoreWarnings` options, allowing developers to selectively exempt certain warnings from being promoted to errors.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic setup, converting all Webpack warnings into errors, and how to ignore specific warnings in Webpack 5.

const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin');

module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: require('path').resolve(__dirname, 'dist'),
  },
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
  // Example for Webpack 5 ignoring a specific warning pattern
  ignoreWarnings: [
    { message: /Critical dependency: the request of a dependency is an expression/ }
  ],
  // For Webpack v2, v3, and v4, use stats.warningsFilter instead of ignoreWarnings
  // stats: {
  //   warningsFilter: [/some warning pattern/]
  // }
};

view raw JSON →