Allows you to hide certain warnings from webpack compilations
npm i -D webpack-filter-warnings-plugin
// 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/
})
]
}
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';
Library exposes only one option: exclude
. It may be one of RegExp
, String
or Function
.
exclude
filterWhen 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.
exclude
filter// webpack.config.js
module.exports = {
// ... rest of webpack config
plugins: [
new FilterWarningsPlugin({
exclude: (input) => /.*hide.*/.test(input),
})
]
}
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.
MIT