File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,21 +27,28 @@ module.exports = class WebpackOptimize {
2727 getCacheVendors ( ) {
2828 const { lib } = this . ctx . config ;
2929 const strRegex = Array . isArray ( lib ) ? lib . join ( '|' ) : '.*' ;
30- const test = new RegExp ( `node_modules/(${ strRegex } )\\.js` ) ;
31- return {
32- name : 'common' ,
30+ const test = new RegExp ( `node_modules/_?(${ strRegex } )(@|/)` ) ;
31+ const options = lib ? {
32+ chunks : 'all' ,
33+ minChunks : 1
34+ } : {
3335 chunks : 'initial' ,
34- minChunks : 2 ,
35- test
36+ minChunks : 2
3637 } ;
38+ return this . ctx . merge ( options , {
39+ name : 'common' ,
40+ test
41+ } ) ;
3742 }
3843
3944 getCacheStyles ( ) {
4045 return {
4146 name : 'common' ,
4247 chunks : 'initial' ,
4348 minChunks : 2 ,
44- test : / \. ( c s s | l e s s | s c s s | s t y l u s ) $ /
49+ test : / \. ( c s s | l e s s | s c s s | s t y l u s ) $ / ,
50+ enforce : true ,
51+ priority : 50
4552 } ;
4653 }
4754
@@ -94,10 +101,10 @@ module.exports = class WebpackOptimize {
94101 splitChunks : {
95102 chunks : 'initial' ,
96103 minSize : 30000 ,
97- maxAsyncRequests : 5 ,
98- maxInitialRequests : 3 ,
104+ minChunks : 1 ,
99105 name : false ,
100106 cacheGroups : {
107+ default : false ,
101108 vendors : this . getCacheVendors ( ) ,
102109 styles : this . getCacheStyles ( )
103110 }
You can’t perform that action at this time.
0 commit comments