UNPKG

@ant-design/tools

Version:
48 lines (47 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; // We should use `stats` props of webpack. But it not work in v4. class CleanUpStatsPlugin { option; constructor(option) { this.option = { MiniCSSExtractPlugin: true, tsLoader: true, ...option }; } shouldPickStatChild(child) { const { MiniCSSExtractPlugin } = this.option; if (MiniCSSExtractPlugin && child.name.includes('mini-css-extract-plugin')) return false; return true; } shouldPickWarning(message) { const { tsLoader } = this.option; if (tsLoader && /export .* was not found in .*/.test(message.details || String(message))) { return false; } return true; } apply(compiler) { compiler.hooks.done.tap('CleanUpStatsPlugin', stats => { const { children, warnings } = stats.compilation; if (Array.isArray(children)) { stats.compilation.children = children.filter(child => this.shouldPickStatChild(child)); } if (Array.isArray(warnings)) { stats.compilation.warnings = warnings.filter(message => this.shouldPickWarning(message)); } }); } } exports.default = CleanUpStatsPlugin;