@@ -4,12 +4,14 @@ import postCSSImport from "postcss-import";
4
4
import postCSSNested from "postcss-nested" ;
5
5
import postCSSNext from "postcss-cssnext" ;
6
6
import path from "path" ;
7
- const ENV = process . env . NODE_ENV || "development" ;
8
7
9
- const CSS_MAPS = ENV !== "production" ;
8
+ const ENV = process . env . NODE_ENV || "development" ;
9
+ const isProduction = ENV === "production" ;
10
+ const CSS_MAPS = ! isProduction ;
10
11
11
12
module . exports = {
12
13
context : path . resolve ( __dirname , "src" ) ,
14
+ mode : isProduction ? "production" : "development" ,
13
15
entry : {
14
16
"netlify-identity-widget" : "./index.js"
15
17
} ,
@@ -65,7 +67,7 @@ module.exports = {
65
67
} ,
66
68
{
67
69
test : / \. ( s v g | w o f f 2 ? | t t f | e o t | j p e ? g | p n g | g i f ) ( \? .* ) ? $ / i,
68
- use : ENV === "production" ? "file-loader" : "url-loader"
70
+ use : isProduction ? "file-loader" : "url-loader"
69
71
}
70
72
]
71
73
} ,
@@ -87,42 +89,7 @@ module.exports = {
87
89
inject : false ,
88
90
minify : { collapseWhitespace : true }
89
91
} )
90
- ] . concat (
91
- ENV === "production"
92
- ? [
93
- new webpack . optimize . UglifyJsPlugin ( {
94
- sourceMap : true ,
95
- output : {
96
- comments : false
97
- } ,
98
- compress : {
99
- unsafe_comps : true ,
100
- properties : true ,
101
- keep_fargs : false ,
102
- pure_getters : true ,
103
- collapse_vars : true ,
104
- unsafe : true ,
105
- warnings : false ,
106
- screw_ie8 : true ,
107
- sequences : true ,
108
- dead_code : true ,
109
- drop_debugger : true ,
110
- comparisons : true ,
111
- conditionals : true ,
112
- evaluate : true ,
113
- booleans : true ,
114
- loops : true ,
115
- unused : true ,
116
- hoist_funs : true ,
117
- if_return : true ,
118
- join_vars : true ,
119
- cascade : true ,
120
- drop_console : false
121
- }
122
- } )
123
- ]
124
- : [ ]
125
- ) ,
92
+ ] ,
126
93
127
94
stats : { colors : true } ,
128
95
@@ -135,7 +102,7 @@ module.exports = {
135
102
setImmediate : false
136
103
} ,
137
104
138
- devtool : ENV === "production" ? "source-map" : "cheap-module-eval-source-map" ,
105
+ devtool : isProduction ? "source-map" : "cheap-module-eval-source-map" ,
139
106
140
107
devServer : {
141
108
port : process . env . PORT || 8080 ,
0 commit comments