diff --git a/src/index.js b/src/index.js index 6f76879e..d89d4fa9 100644 --- a/src/index.js +++ b/src/index.js @@ -825,6 +825,7 @@ class MiniCssExtractPlugin { } return Template.asString([ + 'if (typeof document === "undefined") return;', `var createStylesheet = ${runtimeTemplate.basicFunction( "chunkId, fullhref, oldTag, resolve, reject", [ diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.945622d4f51f3fe3a0d0.css b/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.4568ffdcdfced785eabc.css similarity index 100% rename from test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.945622d4f51f3fe3a0d0.css rename to test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/0.4568ffdcdfced785eabc.css diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/945622d4f51f3fe3a0d0.css b/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/4568ffdcdfced785eabc.css similarity index 100% rename from test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/945622d4f51f3fe3a0d0.css rename to test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/4568ffdcdfced785eabc.css diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js b/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js index 8c4d255c..462b4287 100644 --- a/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js +++ b/test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js @@ -73,7 +73,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/getFullHash */ /******/ (() => { -/******/ __webpack_require__.h = () => ("945622d4f51f3fe3a0d0") +/******/ __webpack_require__.h = () => ("4568ffdcdfced785eabc") /******/ })(); /******/ /******/ /* webpack/runtime/global */ @@ -171,6 +171,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5/0.de494c1e7411c41d8362.css b/test/cases/chunkFilename-fullhash/expected/webpack-5/0.9ee2d65d5d13f2b4323d.css similarity index 100% rename from test/cases/chunkFilename-fullhash/expected/webpack-5/0.de494c1e7411c41d8362.css rename to test/cases/chunkFilename-fullhash/expected/webpack-5/0.9ee2d65d5d13f2b4323d.css diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5/de494c1e7411c41d8362.css b/test/cases/chunkFilename-fullhash/expected/webpack-5/9ee2d65d5d13f2b4323d.css similarity index 100% rename from test/cases/chunkFilename-fullhash/expected/webpack-5/de494c1e7411c41d8362.css rename to test/cases/chunkFilename-fullhash/expected/webpack-5/9ee2d65d5d13f2b4323d.css diff --git a/test/cases/chunkFilename-fullhash/expected/webpack-5/main.js b/test/cases/chunkFilename-fullhash/expected/webpack-5/main.js index 9cbf1619..68c828cc 100644 --- a/test/cases/chunkFilename-fullhash/expected/webpack-5/main.js +++ b/test/cases/chunkFilename-fullhash/expected/webpack-5/main.js @@ -73,7 +73,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/getFullHash */ /******/ (() => { -/******/ __webpack_require__.h = () => ("de494c1e7411c41d8362") +/******/ __webpack_require__.h = () => ("9ee2d65d5d13f2b4323d") /******/ })(); /******/ /******/ /* webpack/runtime/global */ @@ -171,6 +171,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/cases/hmr/expected/main.js b/test/cases/hmr/expected/main.js index eebf4011..581539a3 100644 --- a/test/cases/hmr/expected/main.js +++ b/test/cases/hmr/expected/main.js @@ -934,6 +934,7 @@ __webpack_require__.r(__webpack_exports__); /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/cases/insert-function/expected/main.js b/test/cases/insert-function/expected/main.js index 0034d7cf..96349f1f 100644 --- a/test/cases/insert-function/expected/main.js +++ b/test/cases/insert-function/expected/main.js @@ -155,6 +155,7 @@ /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/cases/insert-string/expected/main.js b/test/cases/insert-string/expected/main.js index 05e9aaeb..04dd03fd 100644 --- a/test/cases/insert-string/expected/main.js +++ b/test/cases/insert-string/expected/main.js @@ -155,6 +155,7 @@ /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/cases/insert-undefined/expected/main.js b/test/cases/insert-undefined/expected/main.js index 907e94ad..ea87a2bc 100644 --- a/test/cases/insert-undefined/expected/main.js +++ b/test/cases/insert-undefined/expected/main.js @@ -155,6 +155,7 @@ /******/ /******/ /* webpack/runtime/css loading */ /******/ (() => { +/******/ if (typeof document === "undefined") return; /******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { /******/ var linkTag = document.createElement("link"); /******/ diff --git a/test/manual/index.html b/test/manual/index.html index 610b7268..3b7d2ca4 100644 --- a/test/manual/index.html +++ b/test/manual/index.html @@ -5,7 +5,7 @@