New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

warnings-to-errors-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warnings-to-errors-webpack-plugin

Change every warning as error to ensure safe build

  • 2.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
increased by14.39%
Maintainers
1
Weekly downloads
 
Created
Source

Warnings To Errors Webpack Plugin Build Status

Table of contents

Motivation

Even if the build result with webpack has some warnings, the build can succeed with no error exit codes. This can be trouble if some developer not carefully sees the result of CI service. By changing all warnings to errors, webpack can recognize every warning as an error.

Installation

$ npm i -D warnings-to-errors-webpack-plugin
# or
$ yarn add -D warnings-to-errors-webpack-plugin

Usage

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

module.exports = {
  // ...
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
};

This plugin ignores warnings that are matched by warningsFilter or ignoreWarnings without recognizing them as errors.

// webpack v5
{
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
  ignoreWarnings: [
    {
      message: /compilation warning/,
    },
  ],
}

If you use ignoreWarnings and warningsFilter options at the same time in webpack v5, the plugin will ignore all matched warnings in both. but recommend using ignoreWarnings.

// webpack v5
{
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
  ignoreWarnings: [
    {
      message: /compilation warning 1/,
    },
  ],
  stats: {
    warningsFilter: [
      /compilation warning 2/,
    ],
  },
}
// webpack v2, v3 and v4
{
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
  stats: {
    warningsFilter: [
      /compilation warning/,
    ],
  },
}

Skip the emitting phase whenever there are warnings while compiling. this ensures that no assets are emitted that include warnings.

// webpack >= v4
{
  optimization: {
    noEmitOnErrors: true,
  },
  plugins: [
    new WarningsToErrorsPlugin();
  ],
};
// webpack v2 and v3
{
  plugins: [
    new WarningsToErrorsPlugin(),
    new NoEmitOnErrorsPlugin(),
  ],
};

License

MIT © Taehwan Noh

Keywords

FAQs

Package last updated on 26 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc