@@ -118,8 +118,8 @@ var wpOpt = require("webpack/bin/convert-argv")(yargs, argv, {
118
118
119
119
function processOptions ( wpOpt ) {
120
120
//process Promise
121
- if ( typeof wpOpt . then === "function" ) {
122
- wpOpt . then ( processOptions ) . catch ( function ( err ) {
121
+ if ( typeof wpOpt . then === "function" ) {
122
+ wpOpt . then ( processOptions ) . catch ( function ( err ) {
123
123
console . error ( err . stack || err ) ;
124
124
process . exit ( ) ; // eslint-disable-line
125
125
} ) ;
@@ -130,112 +130,112 @@ function processOptions(wpOpt) {
130
130
131
131
var options = wpOpt . devServer || firstWpOpt . devServer || { } ;
132
132
133
- if ( argv . host !== "localhost" || ! options . host )
133
+ if ( argv . host !== "localhost" || ! options . host )
134
134
options . host = argv . host ;
135
135
136
- if ( argv . public )
136
+ if ( argv . public )
137
137
options . public = argv . public ;
138
138
139
- if ( argv . port !== 8080 || ! options . port )
139
+ if ( argv . port !== 8080 || ! options . port )
140
140
options . port = argv . port ;
141
141
142
- if ( ! options . publicPath ) {
142
+ if ( ! options . publicPath ) {
143
143
options . publicPath = firstWpOpt . output && firstWpOpt . output . publicPath || "" ;
144
- if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . publicPath ) && options . publicPath [ 0 ] !== "/" )
144
+ if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . publicPath ) && options . publicPath [ 0 ] !== "/" )
145
145
options . publicPath = "/" + options . publicPath ;
146
146
}
147
147
148
- if ( ! options . outputPath )
148
+ if ( ! options . outputPath )
149
149
options . outputPath = "/" ;
150
- if ( ! options . filename )
150
+ if ( ! options . filename )
151
151
options . filename = firstWpOpt . output && firstWpOpt . output . filename ;
152
- [ ] . concat ( wpOpt ) . forEach ( function ( wpOpt ) {
152
+ [ ] . concat ( wpOpt ) . forEach ( function ( wpOpt ) {
153
153
wpOpt . output . path = "/" ;
154
154
} ) ;
155
155
156
- if ( ! options . watchOptions )
156
+ if ( ! options . watchOptions )
157
157
options . watchOptions = firstWpOpt . watchOptions ;
158
158
159
- if ( argv [ "stdin" ] ) {
160
- process . stdin . on ( 'end' , function ( ) {
159
+ if ( argv [ "stdin" ] ) {
160
+ process . stdin . on ( 'end' , function ( ) {
161
161
process . exit ( 0 ) ;
162
162
} ) ;
163
163
process . stdin . resume ( ) ;
164
164
}
165
165
166
- if ( ! options . watchDelay && ! options . watchOptions ) // TODO remove in next major version
166
+ if ( ! options . watchDelay && ! options . watchOptions ) // TODO remove in next major version
167
167
options . watchDelay = firstWpOpt . watchDelay ;
168
168
169
- if ( ! options . hot )
169
+ if ( ! options . hot )
170
170
options . hot = argv [ "hot" ] ;
171
171
172
- if ( argv [ "content-base" ] ) {
172
+ if ( argv [ "content-base" ] ) {
173
173
options . contentBase = argv [ "content-base" ] ;
174
- if ( / ^ [ 0 - 9 ] $ / . test ( options . contentBase ) )
174
+ if ( / ^ [ 0 - 9 ] $ / . test ( options . contentBase ) )
175
175
options . contentBase = + options . contentBase ;
176
- else if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . contentBase ) )
176
+ else if ( ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( options . contentBase ) )
177
177
options . contentBase = path . resolve ( options . contentBase ) ;
178
- } else if ( argv [ "content-base-target" ] ) {
178
+ } else if ( argv [ "content-base-target" ] ) {
179
179
options . contentBase = {
180
180
target : argv [ "content-base-target" ]
181
181
} ;
182
- } else if ( ! options . contentBase ) {
182
+ } else if ( ! options . contentBase ) {
183
183
options . contentBase = process . cwd ( ) ;
184
184
}
185
185
186
- if ( ! options . stats ) {
186
+ if ( ! options . stats ) {
187
187
options . stats = {
188
188
cached : false ,
189
189
cachedAssets : false
190
190
} ;
191
191
}
192
192
193
- if ( typeof options . stats === "object" && typeof options . stats . colors === "undefined" )
193
+ if ( typeof options . stats === "object" && typeof options . stats . colors === "undefined" )
194
194
options . stats . colors = require ( "supports-color" ) ;
195
195
196
- if ( argv [ "lazy" ] )
196
+ if ( argv [ "lazy" ] )
197
197
options . lazy = true ;
198
198
199
- if ( ! argv [ "info" ] )
199
+ if ( ! argv [ "info" ] )
200
200
options . noInfo = true ;
201
201
202
- if ( argv [ "quiet" ] )
202
+ if ( argv [ "quiet" ] )
203
203
options . quiet = true ;
204
204
205
- if ( argv [ "https" ] )
205
+ if ( argv [ "https" ] )
206
206
options . https = true ;
207
207
208
- if ( argv [ "cert" ] )
208
+ if ( argv [ "cert" ] )
209
209
options . cert = fs . readFileSync ( path . resolve ( argv [ "cert" ] ) ) ;
210
210
211
- if ( argv [ "key" ] )
211
+ if ( argv [ "key" ] )
212
212
options . key = fs . readFileSync ( path . resolve ( argv [ "key" ] ) ) ;
213
213
214
- if ( argv [ "cacert" ] )
214
+ if ( argv [ "cacert" ] )
215
215
options . cacert = fs . readFileSync ( path . resolve ( argv [ "cacert" ] ) ) ;
216
216
217
- if ( argv [ "inline" ] === false )
217
+ if ( argv [ "inline" ] === false )
218
218
options . inline = false ;
219
219
220
- if ( argv [ "history-api-fallback" ] )
220
+ if ( argv [ "history-api-fallback" ] )
221
221
options . historyApiFallback = true ;
222
222
223
- if ( argv [ "compress" ] )
223
+ if ( argv [ "compress" ] )
224
224
options . compress = true ;
225
225
226
- if ( argv [ "open" ] )
226
+ if ( argv [ "open" ] )
227
227
options . open = true ;
228
228
229
229
var protocol = options . https ? "https" : "http" ;
230
230
231
- if ( options . inline !== false ) {
231
+ if ( options . inline !== false ) {
232
232
var devClient = [ require . resolve ( "../client/" ) + "?" + protocol + "://" + ( options . public || ( options . host + ":" + options . port ) ) ] ;
233
233
234
- if ( options . hot )
234
+ if ( options . hot )
235
235
devClient . push ( "webpack/hot/dev-server" ) ;
236
- [ ] . concat ( wpOpt ) . forEach ( function ( wpOpt ) {
237
- if ( typeof wpOpt . entry === "object" && ! Array . isArray ( wpOpt . entry ) ) {
238
- Object . keys ( wpOpt . entry ) . forEach ( function ( key ) {
236
+ [ ] . concat ( wpOpt ) . forEach ( function ( wpOpt ) {
237
+ if ( typeof wpOpt . entry === "object" && ! Array . isArray ( wpOpt . entry ) ) {
238
+ Object . keys ( wpOpt . entry ) . forEach ( function ( key ) {
239
239
wpOpt . entry [ key ] = devClient . concat ( wpOpt . entry [ key ] ) ;
240
240
} ) ;
241
241
} else {
@@ -244,26 +244,26 @@ function processOptions(wpOpt) {
244
244
} ) ;
245
245
}
246
246
247
- new Server ( webpack ( wpOpt ) , options ) . listen ( options . port , options . host , function ( err ) {
248
- if ( err ) throw err ;
247
+ new Server ( webpack ( wpOpt ) , options ) . listen ( options . port , options . host , function ( err ) {
248
+ if ( err ) throw err ;
249
249
250
250
var uri = protocol + "://" + options . host + ":" + options . port + "/" ;
251
- if ( options . inline === false )
251
+ if ( options . inline === false )
252
252
uri += "webpack-dev-server/" ;
253
253
console . log ( uri ) ;
254
254
255
255
console . log ( "webpack result is served from " + options . publicPath ) ;
256
- if ( Array . isArray ( options . contentBase ) )
256
+ if ( Array . isArray ( options . contentBase ) )
257
257
console . log ( "content is served from " + options . contentBase . join ( ", " ) ) ;
258
- else if ( typeof options . contentBase === "object" )
258
+ else if ( typeof options . contentBase === "object" )
259
259
console . log ( "requests are proxied to " + options . contentBase . target ) ;
260
260
else
261
261
console . log ( "content is served from " + options . contentBase ) ;
262
- if ( options . historyApiFallback )
262
+ if ( options . historyApiFallback )
263
263
console . log ( "404s will fallback to %s" , options . historyApiFallback . index || "/index.html" ) ;
264
- if ( options . open )
264
+ if ( options . open )
265
265
open ( uri ) ;
266
266
} ) ;
267
267
}
268
268
269
- processOptions ( wpOpt ) ;
269
+ processOptions ( wpOpt ) ;
0 commit comments