JSPM

webpack-filter-warnings-plugin

2.0.0-beta.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1086452
  • Score
    100M100P100Q207350F
  • License MIT

Allows you to hide certain warnings from webpack compilations

Package Exports

  • webpack-filter-warnings-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webpack-filter-warnings-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

webpack-filter-warnings-plugin

npm node deps tests coverage

Allows you to hide certain warnings from webpack compilations

Install

npm i -D webpack-filter-warnings-plugin

Usage

// webpack.config.js
const { FilterWarningsPlugin } = require('webpack-filter-warnings-plugin');

module.exports = {
  // ... rest of webpack config
  plugins: [
    new FilterWarningsPlugin({ 
      exclude: /any-warnings-matching-this-will-be-hidden/ 
    })
  ]
}

Using with Typescript

Webpack Filter Warnings Plugin is completely written in Typescript. As such, it exposes Typescript bindings.

Before using it, install webpack typings:

npm i --save-dev @types/webpack

or

yarn add --dev @types/webpack

Use ES imports:

// webpack.config.ts
import { FilterWarningsPlugin } from 'webpack-filter-warnings-plugin';

Options

Library exposes only one option: exclude. It may be one of RegExp, String or Function.

String as exclude filter

When passing string as exclude parameter, phrase is converted to wildcard and matches any phrase that contains it.

// webpack.config.js
module.exports = {
  // ... rest of webpack config
  plugins: [
    new FilterWarningsPlugin({ 
      exclude: 'hide me'
    })
  ]
}

This config will match any of Should hide me, Hide me, please, HiDe Me (filter is case insensitive) etc.

Function as exclude filter

// webpack.config.js
module.exports = {
  // ... rest of webpack config
  plugins: [
    new FilterWarningsPlugin({ 
      exclude: (input) => /.*hide.*/.test(input),
    })
  ]
}

Why not use the built in stats.warningsFilter option?

Currently karma-webpack does not respect the stats.warningsFilter option. Also when excluding all warnings, webpack still says Compiled with warnings. when all warnings are filtered. Hopefully this plugin will no longer need to exist one day.

Licence

MIT