@@ -14,7 +14,7 @@ const autoprefixer = require('autoprefixer');
14
14
const path = require ( 'path' ) ;
15
15
const fs = require ( 'fs' ) ;
16
16
const webpack = require ( 'webpack' ) ;
17
- const WebpackMd5Hash = require ( 'webpack-md5-hash ' ) ;
17
+ const NameAllModulesPlugin = require ( 'name-all-modules-plugin ' ) ;
18
18
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
19
19
const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
20
20
const ManifestPlugin = require ( 'webpack-manifest-plugin' ) ;
@@ -264,6 +264,41 @@ module.exports = {
264
264
] ,
265
265
} ,
266
266
plugins : [
267
+ // configuration for vendor splitting and long term caching
268
+ // more info: https://medium.com/webpack/predictable-long-term-caching-with-webpack-d3eee1d3fa31
269
+ new webpack . NamedModulesPlugin ( ) ,
270
+ new webpack . NamedChunksPlugin ( chunk => {
271
+ if ( chunk . name ) {
272
+ return chunk . name ;
273
+ }
274
+ return chunk . modules
275
+ . map ( m => path . relative ( m . context , m . request ) )
276
+ . join ( '_' ) ;
277
+ } ) ,
278
+ new webpack . optimize . CommonsChunkPlugin (
279
+ // Check if vendor file exists, if it does,
280
+ // generate a seperate chucks for vendor
281
+ // else don't generate any common chunck
282
+ checkIfVendorFileExists
283
+ ? {
284
+ name : 'vendor' ,
285
+ minChunks : Infinity ,
286
+ }
287
+ : { names : [ ] }
288
+ ) ,
289
+ // We need to extract out the runtime into a separate manifest file.
290
+ // more info: https://webpack.js.org/guides/code-splitting-libraries/#manifest-file
291
+ new webpack . optimize . CommonsChunkPlugin (
292
+ // Check if vendor file exists, if it does,
293
+ // generate a seperate chucks for manifest file
294
+ // else don't generate any common chunck
295
+ checkIfVendorFileExists
296
+ ? {
297
+ name : 'manifest' ,
298
+ }
299
+ : { names : [ ] }
300
+ ) ,
301
+ new NameAllModulesPlugin ( ) ,
267
302
// Makes some environment variables available in index.html.
268
303
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
269
304
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
@@ -292,17 +327,6 @@ module.exports = {
292
327
// It is absolutely essential that NODE_ENV was set to production here.
293
328
// Otherwise React will be compiled in the very slow development mode.
294
329
new webpack . DefinePlugin ( env . stringified ) ,
295
- // We need to extract out the runtime into a separate manifest file.
296
- // more info: https://webpack.js.org/guides/code-splitting-libraries/#manifest-file
297
- new webpack . optimize . CommonsChunkPlugin ( {
298
- // Check if vendor file exists, if it does,
299
- // generate a seperate chucks for vendor and manifest file
300
- // else don't generate any common chunck
301
- names : checkIfVendorFileExists ? [ 'vendor' , 'manifest' ] : [ ] ,
302
- } ) ,
303
- // Need this plugin for deterministic hashing
304
- // until this issue is resolved: https://github.com/webpack/webpack/issues/1315
305
- new WebpackMd5Hash ( ) ,
306
330
// Minify the code.
307
331
new webpack . optimize . UglifyJsPlugin ( {
308
332
compress : {
0 commit comments