Skip to content

taehwanno/warnings-to-errors-webpack-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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