Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: do not crash on using [fullhash]
  • Loading branch information
alexander-akait committed Feb 6, 2021
commit 9911e6b0b9a81d5249657105e07e0081119f8fd3
19,600 changes: 19,065 additions & 535 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"webpack-sources": "^1.1.0"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webpack-contrib/defaults": "^6.3.0",
Expand All @@ -63,20 +63,20 @@
"del": "^6.0.0",
"del-cli": "^3.0.1",
"es-check": "^5.2.0",
"eslint": "^7.18.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
"jsdom": "^16.4.0",
"lint-staged": "^10.5.3",
"lint-staged": "^10.5.4",
"memfs": "^3.0.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"standard-version": "^9.1.0",
"webpack": "^5.18.0",
"webpack-cli": "^4.4.0",
"webpack": "^5.21.1",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.7.2"
},
"keywords": [
Expand Down
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,12 @@ class MiniCssExtractPlugin {

enabledChunks.add(chunk);

// eslint-disable-next-line global-require
const CssLoadingRuntimeModule = require('./CssLoadingRuntimeModule');
if (
typeof this.options.chunkFilename === 'string' &&
/\[(full)?hash(:\d+)?\]/.test(this.options.chunkFilename)
) {
set.add(webpack.RuntimeGlobals.getFullHash);
}

set.add(webpack.RuntimeGlobals.publicPath);

Expand All @@ -503,6 +507,10 @@ class MiniCssExtractPlugin {
true
)
);

// eslint-disable-next-line global-require
const CssLoadingRuntimeModule = require('./CssLoadingRuntimeModule');

compilation.addRuntimeModule(
chunk,
new CssLoadingRuntimeModule(set, this.runtimeOptions)
Expand Down
3 changes: 3 additions & 0 deletions test/cases/chunkFilename-fullhash/async.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.async {
color: red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.async {
color: red;
}

13 changes: 13 additions & 0 deletions test/cases/chunkFilename-fullhash/expected/webpack-5/async.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(self["webpackChunk"] = self["webpackChunk"] || []).push([[0],{

/***/ 2:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ })

}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background: red;
}

Loading