Skip to content

Commit 355f729

Browse files
docs: update (#820)
1 parent 0ccdb64 commit 355f729

File tree

52 files changed

+303
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+303
-67
lines changed

README.md

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,6 @@ module.exports = {
753753
styles: {
754754
name: "styles",
755755
type: "css/mini-extract",
756-
// For webpack@4
757-
// test: /\.css$/,
758756
chunks: "all",
759757
enforce: true,
760758
},
@@ -789,24 +787,6 @@ This also prevents the CSS duplication issue one had with the ExtractTextPlugin.
789787
const path = require("path");
790788
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
791789

792-
function recursiveIssuer(m, c) {
793-
const issuer = c.moduleGraph.getIssuer(m);
794-
// For webpack@4 issuer = m.issuer
795-
796-
if (issuer) {
797-
return recursiveIssuer(issuer, c);
798-
}
799-
800-
const chunks = c.chunkGraph.getModuleChunks(m);
801-
// For webpack@4 chunks = m._chunks
802-
803-
for (const chunk of chunks) {
804-
return chunk.name;
805-
}
806-
807-
return false;
808-
}
809-
810790
module.exports = {
811791
entry: {
812792
foo: path.resolve(__dirname, "src/foo"),
@@ -816,19 +796,19 @@ module.exports = {
816796
splitChunks: {
817797
cacheGroups: {
818798
fooStyles: {
799+
type: "css/mini-extract",
819800
name: "styles_foo",
820-
test: (m, c, entry = "foo") =>
821-
m.constructor.name === "CssModule" &&
822-
recursiveIssuer(m, c) === entry,
823-
chunks: "all",
801+
chunks: (chunk) => {
802+
return chunk.name === "foo";
803+
},
824804
enforce: true,
825805
},
826806
barStyles: {
807+
type: "css/mini-extract",
827808
name: "styles_bar",
828-
test: (m, c, entry = "bar") =>
829-
m.constructor.name === "CssModule" &&
830-
recursiveIssuer(m, c) === entry,
831-
chunks: "all",
809+
chunks: (chunk) => {
810+
return chunk.name === "bar";
811+
},
832812
enforce: true,
833813
},
834814
},

package-lock.json

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cases/chunkFilename-fullhash/expected/webpack-5-importModule/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ __webpack_require__.r(__webpack_exports__);
6666
/******/ (() => {
6767
/******/ // This function allow to reference all chunks
6868
/******/ __webpack_require__.miniCssF = (chunkId) => {
69+
/******/ // return url for filenames not based on template
70+
/******/ if (chunkId === 1) return "" + __webpack_require__.h() + ".css";
6971
/******/ // return url for filenames based on template
7072
/******/ return "" + chunkId + "." + __webpack_require__.h() + ".css";
7173
/******/ };

test/cases/chunkFilename-fullhash/expected/webpack-5/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ __webpack_require__.r(__webpack_exports__);
6666
/******/ (() => {
6767
/******/ // This function allow to reference all chunks
6868
/******/ __webpack_require__.miniCssF = (chunkId) => {
69+
/******/ // return url for filenames not based on template
70+
/******/ if (chunkId === 1) return "" + __webpack_require__.h() + ".css";
6971
/******/ // return url for filenames based on template
7072
/******/ return "" + chunkId + "." + __webpack_require__.h() + ".css";
7173
/******/ };

test/cases/es-named-export-output-module/expected/main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ __webpack_require__.r(__webpack_exports__);
7979

8080

8181
// eslint-disable-next-line no-console
82-
console.log({ css: _style_css__WEBPACK_IMPORTED_MODULE_0__.default, aClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.aClass, bClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.bClass, cClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.cClass });
82+
console.log({ css: _style_css__WEBPACK_IMPORTED_MODULE_0__["default"], aClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.aClass, bClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.bClass, cClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.cClass });
8383

8484
})();
8585

test/cases/es-named-export/expected/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ __webpack_require__.r(__webpack_exports__);
8181

8282

8383
// eslint-disable-next-line no-console
84-
console.log({ css: _style_css__WEBPACK_IMPORTED_MODULE_0__.default, aClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.aClass, bClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.bClass, cClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.cClass });
84+
console.log({ css: _style_css__WEBPACK_IMPORTED_MODULE_0__["default"], aClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.aClass, bClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.bClass, cClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.cClass });
8585

8686
})();
8787

test/cases/hmr/expected/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ module.exports = function (urlString) {
365365
/******/ // This function allow to reference all chunks
366366
/******/ __webpack_require__.miniCssF = (chunkId) => {
367367
/******/ // return url for filenames based on template
368-
/******/ return undefined;
368+
/******/ return "" + "main" + ".css";
369369
/******/ };
370370
/******/ })();
371371
/******/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.class_a {
2+
background: red;
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import "./a.css";
2+
3+
import(/* webpackChunkName: "common" */ "./common");
4+
5+
import(/* webpackChunkName: "comp1" */ "./components/comp1");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.class_b {
2+
background: red;
3+
}

0 commit comments

Comments
 (0)