1
1
'use strict' ;
2
2
3
+ const normalizeOption = ( option ) => ( typeof option === 'object' ? option : { } ) ;
4
+
3
5
module . exports = {
4
6
devServer : [
5
7
{
@@ -47,7 +49,7 @@ module.exports = {
47
49
] ,
48
50
description : 'Directory for static contents.' ,
49
51
processor ( opts ) {
50
- opts . static = opts . static || { } ;
52
+ opts . static = normalizeOption ( opts . static ) ;
51
53
opts . static . directory = opts . staticDirectory ;
52
54
delete opts . staticDirectory ;
53
55
} ,
@@ -64,7 +66,7 @@ module.exports = {
64
66
'The bundled files will be available in the browser under this path.' ,
65
67
multiple : true ,
66
68
processor ( opts ) {
67
- opts . static = opts . static || { } ;
69
+ opts . static = normalizeOption ( opts . static ) ;
68
70
opts . static . publicPath = opts . staticPublicPath ;
69
71
delete opts . staticPublicPath ;
70
72
} ,
@@ -82,7 +84,7 @@ module.exports = {
82
84
'Do not tell dev-server to use serveIndex middleware.' ,
83
85
negative : true ,
84
86
processor ( opts ) {
85
- opts . static = opts . static || { } ;
87
+ opts . static = normalizeOption ( opts . static ) ;
86
88
opts . static . serveIndex = opts . staticServeIndex ;
87
89
delete opts . staticServeIndex ;
88
90
} ,
@@ -99,7 +101,7 @@ module.exports = {
99
101
negatedDescription : 'Do not watch for files in static content directory.' ,
100
102
negative : true ,
101
103
processor ( opts ) {
102
- opts . static = opts . static || { } ;
104
+ opts . static = normalizeOption ( opts . static ) ;
103
105
opts . static . watch = opts . staticWatch ;
104
106
delete opts . staticWatch ;
105
107
} ,
@@ -138,7 +140,7 @@ module.exports = {
138
140
] ,
139
141
description : 'Passphrase for a pfx file.' ,
140
142
processor ( opts ) {
141
- opts . https = opts . https || { } ;
143
+ opts . https = normalizeOption ( opts . https ) ;
142
144
opts . https . passphrase = opts . httpsPassphrase ;
143
145
delete opts . httpsPassphrase ;
144
146
} ,
@@ -153,7 +155,7 @@ module.exports = {
153
155
] ,
154
156
description : 'Path to an SSL key.' ,
155
157
processor ( opts ) {
156
- opts . https = opts . https || { } ;
158
+ opts . https = normalizeOption ( opts . https ) ;
157
159
opts . https . key = opts . httpsKey ;
158
160
delete opts . httpsKey ;
159
161
} ,
@@ -168,7 +170,7 @@ module.exports = {
168
170
] ,
169
171
description : 'Path to an SSL pfx file.' ,
170
172
processor ( opts ) {
171
- opts . https = opts . https || { } ;
173
+ opts . https = normalizeOption ( opts . https ) ;
172
174
opts . https . pfx = opts . httpsPfx ;
173
175
delete opts . httpsPfx ;
174
176
} ,
@@ -183,7 +185,7 @@ module.exports = {
183
185
] ,
184
186
description : 'Path to an SSL certificate.' ,
185
187
processor ( opts ) {
186
- opts . https = opts . https || { } ;
188
+ opts . https = normalizeOption ( opts . https ) ;
187
189
opts . https . cert = opts . httpsCert ;
188
190
delete opts . httpsCert ;
189
191
} ,
@@ -198,7 +200,7 @@ module.exports = {
198
200
] ,
199
201
description : 'Path to an SSL CA certificate.' ,
200
202
processor ( opts ) {
201
- opts . https = opts . https || { } ;
203
+ opts . https = normalizeOption ( opts . https ) ;
202
204
opts . https . cacert = opts . httpsCacert ;
203
205
delete opts . httpsCacert ;
204
206
} ,
@@ -214,7 +216,7 @@ module.exports = {
214
216
description : 'Request for an SSL certificate.' ,
215
217
negatedDescription : 'Do not request for an SSL certificate.' ,
216
218
processor ( opts ) {
217
- opts . https = opts . https || { } ;
219
+ opts . https = normalizeOption ( opts . https ) ;
218
220
opts . https . requestCert = opts . httpsRequestCert ;
219
221
delete opts . httpsRequestCert ;
220
222
} ,
@@ -257,7 +259,7 @@ module.exports = {
257
259
'Do not tell devServer to inject a Hot Module Replacement entry.' ,
258
260
negative : true ,
259
261
processor ( opts ) {
260
- opts . client = opts . client || { } ;
262
+ opts . client = normalizeOption ( opts . client ) ;
261
263
opts . client . hotEntry = opts . clientHotEntry ;
262
264
delete opts . clientHotEntry ;
263
265
} ,
@@ -275,7 +277,7 @@ module.exports = {
275
277
'Do not print compilation progress in percentage in the browser.' ,
276
278
negative : true ,
277
279
processor ( opts ) {
278
- opts . client = opts . client || { } ;
280
+ opts . client = normalizeOption ( opts . client ) ;
279
281
opts . client . progress = opts . clientProgress ;
280
282
delete opts . clientProgress ;
281
283
} ,
@@ -294,11 +296,27 @@ module.exports = {
294
296
'Do not show a full-screen overlay in the browser when there are compiler errors or warnings.' ,
295
297
negative : true ,
296
298
processor ( opts ) {
297
- opts . client = opts . client || { } ;
299
+ opts . client = normalizeOption ( opts . client ) ;
298
300
opts . client . overlay = opts . clientOverlay ;
299
301
delete opts . clientOverlay ;
300
302
} ,
301
303
} ,
304
+ {
305
+ name : 'client-logging' ,
306
+ type : String ,
307
+ configs : [
308
+ {
309
+ type : 'string' ,
310
+ } ,
311
+ ] ,
312
+ description :
313
+ 'Log level in the browser (none, error, warn, info, log, verbose).' ,
314
+ processor ( opts ) {
315
+ opts . client = normalizeOption ( opts . client ) ;
316
+ opts . client . logging = opts . clientLogging ;
317
+ delete opts . clientLogging ;
318
+ } ,
319
+ } ,
302
320
{
303
321
name : 'open' ,
304
322
type : [ Boolean , String ] ,
@@ -325,7 +343,7 @@ module.exports = {
325
343
] ,
326
344
description : 'Open specified browser.' ,
327
345
processor ( opts ) {
328
- opts . open = opts . open || { } ;
346
+ opts . open = normalizeOption ( opts . open ) ;
329
347
opts . open . app = opts . openApp ;
330
348
delete opts . openApp ;
331
349
} ,
@@ -343,30 +361,14 @@ module.exports = {
343
361
] ,
344
362
description : 'Open specified route in browser.' ,
345
363
processor ( opts ) {
346
- opts . open = opts . open || { } ;
364
+ opts . open = normalizeOption ( opts . open ) ;
347
365
opts . open . target = opts . openTarget ;
348
366
delete opts . openTarget ;
349
367
} ,
350
368
negatedDescription : 'Do not open specified route in browser.' ,
351
369
multiple : true ,
352
370
negative : true ,
353
371
} ,
354
- {
355
- name : 'client-logging' ,
356
- type : String ,
357
- configs : [
358
- {
359
- type : 'string' ,
360
- } ,
361
- ] ,
362
- description :
363
- 'Log level in the browser (none, error, warn, info, log, verbose).' ,
364
- processor ( opts ) {
365
- opts . client = opts . client || { } ;
366
- opts . client . logging = opts . clientLogging ;
367
- delete opts . clientLogging ;
368
- } ,
369
- } ,
370
372
{
371
373
name : 'history-api-fallback' ,
372
374
type : Boolean ,
0 commit comments