@@ -4,7 +4,6 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin';
44import nodeExternals from 'webpack-node-externals' ;
55import path from 'path' ;
66import webpack from 'webpack' ;
7- import WebpackMd5Hash from 'webpack-md5-hash' ;
87
98import { happyPackPlugin , log } from '../utils' ;
109import { ifElse } from '../../shared/utils/logic' ;
@@ -55,15 +54,17 @@ export default function webpackConfigFactory(buildOptions) {
5554 const bundleConfig =
5655 isServer || isClient
5756 ? // This is either our "server" or "client" bundle.
58- config ( [ 'bundles' , target ] )
57+ config ( [ 'bundles' , target ] )
5958 : // Otherwise it must be an additional node bundle.
60- config ( [ 'additionalNodeBundles' , target ] ) ;
59+ config ( [ 'additionalNodeBundles' , target ] ) ;
6160
6261 if ( ! bundleConfig ) {
6362 throw new Error ( 'No bundle configuration exists for target:' , target ) ;
6463 }
6564
6665 let webpackConfig = {
66+ // Webpack Mode
67+ mode : ifDev ( 'development' , 'production' ) ,
6768 // Define our entry chunks for our bundle.
6869 entry : {
6970 // We name our entry files "index" as it makes it easier for us to
@@ -80,9 +81,9 @@ export default function webpackConfigFactory(buildOptions) {
8081 // Required to support hot reloading of our client.
8182 ifDevClient (
8283 ( ) =>
83- `webpack-hot-middleware/client?reload=true&path=http://${ config ( 'host' ) } : ${ config (
84- 'clientDevServerPort ' ,
85- ) } /__webpack_hmr`,
84+ `webpack-hot-middleware/client?reload=true&path=http://${ config (
85+ 'host ' ,
86+ ) } : ${ config ( 'clientDevServerPort' ) } /__webpack_hmr`,
8687 ) ,
8788
8889 // The source entry file for the bundle.
@@ -127,9 +128,9 @@ export default function webpackConfigFactory(buildOptions) {
127128
128129 target : isClient
129130 ? // Only our client bundle will target the web as a runtime.
130- 'web'
131+ 'web'
131132 : // Any other bundle must be targetting node as a runtime.
132- 'node' ,
133+ 'node' ,
133134
134135 // Ensure that webpack polyfills the following node features for use
135136 // within any bundles that are targetting node as a runtime. This will be
@@ -177,7 +178,7 @@ export default function webpackConfigFactory(buildOptions) {
177178 // This is required for the modernizr-loader
178179 // @see https://github.com/peerigon/modernizr-loader
179180 alias : {
180- modernizr$ : path . resolve ( appRootDir . get ( ) , './.modernizrrc' ) ,
181+ modernizr$ : path . resolve ( appRootDir . get ( ) , './.modernizrrc.json ' ) ,
181182 } ,
182183 } ,
183184
@@ -227,13 +228,6 @@ export default function webpackConfigFactory(buildOptions) {
227228 // the significant improvement will be how fast the JavaScript loads in the browser.
228229 ifProdClient ( new webpack . optimize . ModuleConcatenationPlugin ( ) ) ,
229230
230- // We use this so that our generated [chunkhash]'s are only different if
231- // the content for our respective chunks have changed. This optimises
232- // our long term browser caching strategy for our client bundle, avoiding
233- // cases where browsers end up having to download all the client chunks
234- // even though 1 or 2 may have only changed.
235- ifClient ( ( ) => new WebpackMd5Hash ( ) ) ,
236-
237231 // These are process.env flags that you can use in your code in order to
238232 // have advanced control over what is included/excluded in your bundles.
239233 // For example you may only want certain parts of your code to be
@@ -408,6 +402,8 @@ export default function webpackConfigFactory(buildOptions) {
408402 // React that the subtree hasn’t changed so React can completely
409403 // skip it when reconciling.
410404 ifProd ( 'transform-react-constant-elements' ) ,
405+ // Add syntax dynamic import for direct webpack `import()` support
406+ 'syntax-dynamic-import' ,
411407 ] . filter ( x => x != null ) ,
412408 } ,
413409 buildOptions ,
@@ -452,7 +448,9 @@ export default function webpackConfigFactory(buildOptions) {
452448 // details on what loader is being implemented.
453449 loader : 'happypack/loader?id=happypack-javascript' ,
454450 include : removeNil ( [
455- ...bundleConfig . srcPaths . map ( srcPath => path . resolve ( appRootDir . get ( ) , srcPath ) ) ,
451+ ...bundleConfig . srcPaths . map ( srcPath =>
452+ path . resolve ( appRootDir . get ( ) , srcPath ) ,
453+ ) ,
456454 ifProdClient ( path . resolve ( appRootDir . get ( ) , 'src/html' ) ) ,
457455 ] ) ,
458456 } ,
@@ -501,10 +499,6 @@ export default function webpackConfigFactory(buildOptions) {
501499 test : / \. m o d e r n i z r r c .j s $ / ,
502500 loader : 'modernizr-loader' ,
503501 } ) ,
504- ifClient ( {
505- test : / \. m o d e r n i z r r c ( \. j s o n ) ? $ / ,
506- loader : 'modernizr-loader!json-loader' ,
507- } ) ,
508502
509503 // ASSETS (Images/Fonts/etc)
510504 // This is bound to our server/client bundles as we only expect to be
@@ -520,12 +514,12 @@ export default function webpackConfigFactory(buildOptions) {
520514 // paths used on the client.
521515 publicPath : isDev
522516 ? // When running in dev mode the client bundle runs on a
523- // seperate port so we need to put an absolute path here.
524- `http://${ config ( 'host' ) } :${ config ( 'clientDevServerPort' ) } ${ config (
525- 'bundles.client.webPath ',
526- ) } `
517+ // seperate port so we need to put an absolute path here.
518+ `http://${ config ( 'host' ) } :${ config (
519+ 'clientDevServerPort ',
520+ ) } ${ config ( 'bundles.client.webPath' ) } `
527521 : // Otherwise we just use the configured web path for the client.
528- config ( 'bundles.client.webPath' ) ,
522+ config ( 'bundles.client.webPath' ) ,
529523 // We only emit files when building a web bundle, for the server
530524 // bundle we only care about the file loader being able to create
531525 // the correct asset URLs.
0 commit comments