|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Tobias Koppers @sokra
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | /** @typedef {import("./Compiler")} Compiler */
|
|---|
| 9 | /** @typedef {import("./Compilation")} Compilation */
|
|---|
| 10 |
|
|---|
| 11 | /** @typedef {(warning: Error, compilation: Compilation) => boolean} IgnoreFn */
|
|---|
| 12 |
|
|---|
| 13 | const PLUGIN_NAME = "IgnoreWarningsPlugin";
|
|---|
| 14 |
|
|---|
| 15 | class IgnoreWarningsPlugin {
|
|---|
| 16 | /**
|
|---|
| 17 | * Creates an instance of IgnoreWarningsPlugin.
|
|---|
| 18 | * @param {IgnoreFn[]} ignoreWarnings conditions to ignore warnings
|
|---|
| 19 | */
|
|---|
| 20 | constructor(ignoreWarnings) {
|
|---|
| 21 | /** @type {IgnoreFn[]} */
|
|---|
| 22 | this._ignoreWarnings = ignoreWarnings;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | /**
|
|---|
| 26 | * Applies the plugin by registering its hooks on the compiler.
|
|---|
| 27 | * @param {Compiler} compiler the compiler instance
|
|---|
| 28 | * @returns {void}
|
|---|
| 29 | */
|
|---|
| 30 | apply(compiler) {
|
|---|
| 31 | compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|---|
| 32 | compilation.hooks.processWarnings.tap(PLUGIN_NAME, (warnings) =>
|
|---|
| 33 | warnings.filter(
|
|---|
| 34 | (warning) =>
|
|---|
| 35 | !this._ignoreWarnings.some((ignore) => ignore(warning, compilation))
|
|---|
| 36 | )
|
|---|
| 37 | );
|
|---|
| 38 | });
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | module.exports = IgnoreWarningsPlugin;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.