File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -52,4 +52,5 @@ module.exports = {
52
52
appNodeModules : resolveApp ( 'node_modules' ) ,
53
53
publicUrl : getPublicUrl ( resolveApp ( 'package.json' ) ) ,
54
54
servedPath : getServedPath ( resolveApp ( 'package.json' ) ) ,
55
+ vendorConfig : resolveApp ( 'config/vendor.config.js' )
55
56
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Created by 叶子 on 2017/9/24.
3
+ */
4
+ module . exports = {
5
+ entry : {
6
+ vendor : [ 'antd' ] , // 需要分离的库
7
+ charts : [ 'echarts-for-react' ]
8
+ }
9
+ } ;
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
44
44
{ publicPath : Array ( cssFilename . split ( '/' ) . length ) . join ( '../' ) }
45
45
: { } ;
46
46
47
+ // add vendor pack
48
+ const vendorEntry = require ( paths . vendorConfig ) . entry ;
49
+
47
50
// This is the production configuration.
48
51
// It compiles slowly and is focused on producing a fast and minimal bundle.
49
52
// The development configuration is different and lives in a separate file.
@@ -54,7 +57,12 @@ module.exports = {
54
57
// You can exclude the *.map files from the build during deployment.
55
58
devtool : 'source-map' ,
56
59
// In production, we only want to load the polyfills and the app code.
57
- entry : [ require . resolve ( './polyfills' ) , paths . appIndexJs ] ,
60
+ entry : Object . assign ( // 合并分离打包入口文件
61
+ {
62
+ main : [ require . resolve ( './polyfills' ) , paths . appIndexJs ]
63
+ } ,
64
+ vendorEntry
65
+ ) ,
58
66
output : {
59
67
// The build folder.
60
68
path : paths . appBuild ,
@@ -264,6 +272,9 @@ module.exports = {
264
272
] ,
265
273
} ,
266
274
plugins : [
275
+ new webpack . optimize . CommonsChunkPlugin ( {
276
+ names : [ 'main' , 'manifest' ] . concat ( Object . keys ( vendorEntry ) )
277
+ } ) ,
267
278
// Makes some environment variables available in index.html.
268
279
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
269
280
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
You can’t perform that action at this time.
0 commit comments