Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

warnings-to-errors-webpack-plugin

2.0.1 • Public • Published

Warnings To Errors Webpack Plugin Build Status

Table of contents

Motivation

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

This can happen especially if you use the resolve.alias option.

  1. webpack configuration
{
  resolve: {
    alias: {
      actions: 'app/state/actions.js'
    }
  }
}
  1. resolve.alias file code
// app/state/actions.js
export const loadUserList = () => {}
  1. import actions in some file. build result has a warning 🐛
// loadUserLists. Not a loadUserList.
import { loadUserLists } from 'actions';
 
// ...

Installation

$ npm install --save-dev warnings-to-errors-webpack-plugin

Alternatively, using yarn.

$ yarn add --dev warnings-to-errors-webpack-plugin

Usage

  • default
const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin');
 
module.exports = {
  // ...
  plugins: [
    new WarningsToErrorsPlugin(),
  ],
};

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

Install

npm i warnings-to-errors-webpack-plugin

DownloadsWeekly Downloads

8,117

Version

2.0.1

License

MIT

Unpacked Size

4.79 kB

Total Files

4

Last publish

Collaborators

  • avatar