Skip to content

Commit

Permalink
fix: bloated runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jan 27, 2021
1 parent 05e2951 commit 5b8ab7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,15 @@ class MiniCssExtractPlugin {
MODULE_TYPE,
'mini-css',
`${webpack.RuntimeGlobals.require}.miniCssF`,
(referencedChunk) =>
referencedChunk.canBeInitial()
(referencedChunk) => {
if (!referencedChunk.contentHash[MODULE_TYPE]) {
return '';
}

return referencedChunk.canBeInitial()
? this.options.filename
: this.options.chunkFilename,
: this.options.chunkFilename;
},
true
)
);
Expand Down
2 changes: 1 addition & 1 deletion test/cases/runtime/expected/webpack-5/runtime~main.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames based on template
/******/ return "" + ({"0":"main","1":"runtime~main"}[chunkId] || chunkId) + "." + {"0":"a7263f8f763dcf4051bc"}[chunkId] + ".css";
/******/ return "" + "main" + "." + "a7263f8f763dcf4051bc" + ".css";
/******/ };
/******/ })();
/******/
Expand Down

0 comments on commit 5b8ab7e

Please sign in to comment.