@@ -6,10 +6,11 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
66var env = process . env . NODE_ENV ;
77var suffix = env === 'production' ? '.min' : '' ;
88var filename = `react-mdl-extra${ suffix } ` ;
9+ var minify = process . env . MINIFY ;
910
1011var config = {
1112 entry : [
12- path . resolve ( __dirname , 'src' , 'index' )
13+ path . resolve ( __dirname , 'src' , 'index' ) ,
1314 ] ,
1415 output : {
1516 path : path . resolve ( __dirname , 'dist' ) ,
@@ -20,23 +21,30 @@ var config = {
2021 resolve : {
2122 extensions : [ '' , '.js' , '.scss' , '.css' ] ,
2223 } ,
24+ externals : {
25+ 'react' : 'react' ,
26+ 'react-dom' : 'reactDOM' ,
27+ } ,
2328 module : {
2429 preLoaders : [ {
2530 test : / \. j s $ / ,
2631 loader : 'eslint' ,
27- exclude : / n o d e _ m o d u l e s /
32+ exclude : / n o d e _ m o d u l e s / ,
2833 } ] ,
2934 loaders : [ {
3035 test : / \. j s $ / ,
3136 loader : 'babel' ,
32- exclude : / n o d e _ m o d u l e s /
37+ exclude : / n o d e _ m o d u l e s / ,
3338 } , {
3439 test : / \. ( s c s s | c s s ) $ / ,
3540 loader : ExtractTextPlugin . extract ( 'css!postcss!sass' ) ,
3641 } ]
3742 } ,
38- postcss : [ autoprefixer ( { browsers : [ 'last 2 versions' ] } ) ] ,
43+ postcss : [
44+ autoprefixer ( { browsers : [ 'last 2 versions' ] } )
45+ ] ,
3946 plugins : [
47+ new webpack . optimize . DedupePlugin ( ) ,
4048 new webpack . optimize . OccurenceOrderPlugin ( ) ,
4149 new webpack . DefinePlugin ( {
4250 'process.env.NODE_ENV' : JSON . stringify ( env )
@@ -45,4 +53,22 @@ var config = {
4553 ] ,
4654} ;
4755
56+ if ( minify ) {
57+ config . plugins . push (
58+ new webpack . optimize . UglifyJsPlugin ( {
59+ compress : {
60+ screw_ie8 : true ,
61+ warnings : false ,
62+ } ,
63+ mangle : {
64+ screw_ie8 : true ,
65+ } ,
66+ output : {
67+ comments : false ,
68+ screw_ie8 : true ,
69+ } ,
70+ } )
71+ ) ;
72+ }
73+
4874module . exports = config
0 commit comments