Skip to content

Commit 19ec95b

Browse files
docs: update splitChunks info (#630)
1 parent 621384c commit 19ec95b

File tree

12 files changed

+101
-6
lines changed

12 files changed

+101
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,16 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
710710
function recursiveIssuer(m) {
711711
if (m.issuer) {
712712
return recursiveIssuer(m.issuer);
713-
} else if (m.name) {
714-
return m.name;
715-
} else {
716-
return false;
717713
}
714+
715+
const chunks = m.getChunks();
716+
// For webpack@4 chunks = m._chunks
717+
718+
for (const chunk of chunks) {
719+
return chunk.name;
720+
}
721+
722+
return false;
718723
}
719724

720725
module.exports = {
@@ -726,14 +731,14 @@ module.exports = {
726731
splitChunks: {
727732
cacheGroups: {
728733
fooStyles: {
729-
name: 'foo',
734+
name: 'styles_foo',
730735
test: (m, c, entry = 'foo') =>
731736
m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry,
732737
chunks: 'all',
733738
enforce: true,
734739
},
735740
barStyles: {
736-
name: 'bar',
741+
name: 'styles_bar',
737742
test: (m, c, entry = 'bar') =>
738743
m.constructor.name === 'CssModule' && recursiveIssuer(m) === entry,
739744
chunks: 'all',
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import './a.css';
2+
3+
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+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import './b.css';
2+
3+
import(/* webpackChunkName: "comp2" */ './components/comp2');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: yellow;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './comp1.css';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: green;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './comp2.css';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.class_a {
2+
background: red;
3+
}
4+
5+
body {
6+
background-color: yellow;
7+
}
8+

0 commit comments

Comments
 (0)