forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update webpack to 4.x (vueComponent#425)
* update webpack to 4.x
- Loading branch information
1 parent
0e78eed
commit c351cba
Showing
13 changed files
with
268 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// We should use `stats` props of webpack. But it not work in v4. | ||
class CleanUpStatsPlugin { | ||
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)) { | ||
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)); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
module.exports = CleanUpStatsPlugin; |
Oops, something went wrong.