@@ -11,25 +11,38 @@ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
1111import { ReactLoadablePlugin } from 'react-loadable/webpack' ;
1212import config from '../config' ;
1313
14- const ssr = yn ( process . env . SSR ) || false ;
15- const isoPlugin = new IsoPlugin ( config . isomorphicConfig ) . development ( isDev ) ;
16- const extractTextPlugin = new ExtractTextPlugin ( {
14+ let ssr = yn ( process . env . SSR ) || false ;
15+ let isoPlugin = new IsoPlugin ( config . isomorphicConfig ) . development ( isDev ) ;
16+ let extractTextPlugin = new ExtractTextPlugin ( {
1717 filename : isDev ? '[name].css' : '[name].[contenthash].css' ,
1818 allChunks : true ,
1919 disable : ssr
2020} ) ;
21- const plugins = [
21+
22+ let plugins = [
2223 isoPlugin ,
23- new ReactLoadablePlugin ( {
24- filename : path . join ( __dirname , '..' , 'react-loadable.json' )
25- } ) ,
2624 extractTextPlugin ,
2725 new webpack . ContextReplacementPlugin ( / m o m e n t [ / \\ ] l o c a l e $ / , / e n | e s / ) ,
2826 new webpack . DefinePlugin ( {
2927 'process.env' : config . clientEnv
3028 } )
3129] ;
3230
31+ let output = {
32+ path : path . join ( __dirname , '..' , process . env . PUBLIC_OUTPUT_PATH ) ,
33+ filename : '[name].bundle.js' ,
34+ publicPath : process . env . PUBLIC_ASSET_PATH || '/'
35+ } ;
36+
37+ // Enable dynamically imported code-splitting
38+ if ( config . enableDynamicImports ) {
39+ plugins . unshift ( new ReactLoadablePlugin ( {
40+ filename : path . join ( __dirname , '..' , 'react-loadable.json' )
41+ } ) ) ;
42+
43+ output . chunkFilename = '[name].bundle.js' ;
44+ }
45+
3346if ( process . env . ANALYZE ) {
3447 plugins . push ( new BundleAnalyzerPlugin ( ) ) ;
3548}
@@ -39,12 +52,7 @@ export default {
3952 entry : {
4053 app : [ './client/index' ]
4154 } ,
42- output : {
43- path : path . join ( __dirname , '..' , process . env . PUBLIC_OUTPUT_PATH ) ,
44- filename : '[name].bundle.js' ,
45- chunkFilename : '[name].bundle.js' ,
46- publicPath : process . env . PUBLIC_ASSET_PATH || '/'
47- } ,
55+ output,
4856 resolve : {
4957 extensions : [ '.js' , '.jsx' , '.scss' ] ,
5058 alias : mapValues ( config . clientResolvePaths , str =>
0 commit comments