@@ -3,11 +3,15 @@ import path from 'path';
33import HtmlWebpackPlugin from 'html-webpack-plugin' ;
44import WebpackMd5Hash from 'webpack-md5-hash' ;
55import ExtractTextPlugin from 'extract-text-webpack-plugin' ;
6+ //debug: true,
7+ //noInfo: false,
68
79export default {
8- debug : true ,
10+ mode : 'production' ,
11+ resolve : {
12+ extensions : [ '*' , '.js' , '.jsx' , '.json' ]
13+ } ,
914 devtool : 'source-map' ,
10- noInfo : false ,
1115 entry : {
1216 vendor : path . resolve ( __dirname , 'src/vendor' ) ,
1317 main : path . resolve ( __dirname , 'src/index' )
@@ -18,19 +22,39 @@ export default {
1822 publicPath : '/' ,
1923 filename : '[name].[chunkhash].js'
2024 } ,
25+ // Webpack 4 removed the commonsChunkPlugin. Use optimization.splitChunks instead.
26+ optimization : {
27+ splitChunks : {
28+ cacheGroups : {
29+ commons : {
30+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
31+ name : 'vendor' ,
32+ chunks : 'all'
33+ }
34+ }
35+ }
36+ } ,
2137 plugins : [
38+ // Global loader configuration
39+ new webpack . LoaderOptionsPlugin ( {
40+ minimize : true ,
41+ debug : false ,
42+ noInfo : true // set to false to see a list of every file being bundled.
43+ } ) ,
44+
2245 // (separate css and js)
2346 // Generate an external css file with a hash in the filename
24- new ExtractTextPlugin ( '[name].[contenthash].css' ) ,
25-
47+ // new ExtractTextPlugin('[name].[contenthash].css'),
48+ new ExtractTextPlugin ( '[name].[md5:contenthash:hex:20].css' ) ,
2649 // Hash the files using MD5 so that their names change when the content changes.
2750 new WebpackMd5Hash ( ) ,
2851
2952 // Use CommonsChunkPlugin to create a separate bundle
3053 // of vendor libraries so that they're cached separately.
31- new webpack . optimize . CommonsChunkPlugin ( {
32- name : 'vendor'
33- } ) ,
54+ // No longer used for Webpack 4. See optimization.splitChunks above instead.
55+ // new webpack.optimize.CommonsChunkPlugin({
56+ // name: 'vendor'
57+ // }),
3458
3559 // Create HTML file that includes reference to bundled JS.
3660 new HtmlWebpackPlugin ( {
@@ -51,18 +75,22 @@ export default {
5175 // Properties you define here are available in index.html
5276 // using htmlWebpackPlugin.options.varName
5377 trackJSToken : 'INSERT YOUR TOKEN HERE'
54- } ) ,
78+ } )
5579
5680 // Eliminate duplicate packages when generating bundle
57- new webpack . optimize . DedupePlugin ( ) ,
81+ // new webpack.optimize.DedupePlugin()
5882
83+ // Code is automatically minified in prod mode as of Webpack 4, so removing this.
5984 // Minify JS
60- new webpack . optimize . UglifyJsPlugin ( )
85+ // new webpack.optimize.UglifyJsPlugin()
6186 ] ,
6287 module : {
63- loaders : [
64- { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loaders : [ 'babel' ] } ,
65- { test : / \. c s s $ / , loader : ExtractTextPlugin . extract ( 'css?sourceMap' ) } // extra param is a hint to webpack
88+ rules : [
89+ { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loaders : [ 'babel-loader' ] } ,
90+ {
91+ test : / \. c s s $ / ,
92+ loader : ExtractTextPlugin . extract ( 'css-loader?sourceMap' )
93+ } // extra param is a hint to webpack
6694 ]
6795 }
6896} ;
0 commit comments