@@ -3,11 +3,15 @@ import path from 'path';
3
3
import HtmlWebpackPlugin from 'html-webpack-plugin' ;
4
4
import WebpackMd5Hash from 'webpack-md5-hash' ;
5
5
import ExtractTextPlugin from 'extract-text-webpack-plugin' ;
6
+ //debug: true,
7
+ //noInfo: false,
6
8
7
9
export default {
8
- debug : true ,
10
+ mode : 'production' ,
11
+ resolve : {
12
+ extensions : [ '*' , '.js' , '.jsx' , '.json' ]
13
+ } ,
9
14
devtool : 'source-map' ,
10
- noInfo : false ,
11
15
entry : {
12
16
vendor : path . resolve ( __dirname , 'src/vendor' ) ,
13
17
main : path . resolve ( __dirname , 'src/index' )
@@ -18,19 +22,39 @@ export default {
18
22
publicPath : '/' ,
19
23
filename : '[name].[chunkhash].js'
20
24
} ,
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
+ } ,
21
37
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
+
22
45
// (separate css and js)
23
46
// 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' ) ,
26
49
// Hash the files using MD5 so that their names change when the content changes.
27
50
new WebpackMd5Hash ( ) ,
28
51
29
52
// Use CommonsChunkPlugin to create a separate bundle
30
53
// 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
+ // }),
34
58
35
59
// Create HTML file that includes reference to bundled JS.
36
60
new HtmlWebpackPlugin ( {
@@ -51,18 +75,22 @@ export default {
51
75
// Properties you define here are available in index.html
52
76
// using htmlWebpackPlugin.options.varName
53
77
trackJSToken : 'INSERT YOUR TOKEN HERE'
54
- } ) ,
78
+ } )
55
79
56
80
// Eliminate duplicate packages when generating bundle
57
- new webpack . optimize . DedupePlugin ( ) ,
81
+ // new webpack.optimize.DedupePlugin()
58
82
83
+ // Code is automatically minified in prod mode as of Webpack 4, so removing this.
59
84
// Minify JS
60
- new webpack . optimize . UglifyJsPlugin ( )
85
+ // new webpack.optimize.UglifyJsPlugin()
61
86
] ,
62
87
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
66
94
]
67
95
}
68
96
} ;
0 commit comments