@@ -66,22 +66,8 @@ class Server {
66
66
67
67
this . log = _log || createLogger ( options ) ;
68
68
69
- // set serverMode default
70
- if ( this . options . serverMode === undefined ) {
71
- this . options . serverMode = 'sockjs' ;
72
- } else {
73
- this . log . warn (
74
- 'serverMode is an experimental option, meaning its usage could potentially change without warning'
75
- ) ;
76
- }
77
- // set clientMode default
78
- if ( this . options . clientMode === undefined ) {
79
- this . options . clientMode = 'sockjs' ;
80
- } else {
81
- this . log . warn (
82
- 'clientMode is an experimental option, meaning its usage could potentially change without warning'
83
- ) ;
84
- }
69
+ // set client and server default mode
70
+ this . setDefaultMode ( ) ;
85
71
86
72
updateCompiler ( this . compiler , this . options ) ;
87
73
@@ -153,6 +139,18 @@ class Server {
153
139
} , this ) ;
154
140
}
155
141
142
+ setDefaultMode ( ) {
143
+ [ 'serverMode' , 'clientMode' ] . forEach ( ( mode ) => {
144
+ if ( this . options [ mode ] === undefined ) {
145
+ this . options [ mode ] = 'sockjs' ;
146
+ } else {
147
+ this . log . warn (
148
+ `${ mode } is an experimental option, meaning its usage could potentially change without warning`
149
+ ) ;
150
+ }
151
+ } ) ;
152
+ }
153
+
156
154
setupProgressPlugin ( ) {
157
155
// for CLI output
158
156
new webpack . ProgressPlugin ( {
@@ -292,14 +290,12 @@ class Server {
292
290
* ]
293
291
*/
294
292
this . options . proxy . forEach ( ( proxyConfigOrCallback ) => {
295
- let proxyConfig ;
296
293
let proxyMiddleware ;
297
294
298
- if ( typeof proxyConfigOrCallback === 'function' ) {
299
- proxyConfig = proxyConfigOrCallback ( ) ;
300
- } else {
301
- proxyConfig = proxyConfigOrCallback ;
302
- }
295
+ let proxyConfig =
296
+ typeof proxyConfigOrCallback === 'function'
297
+ ? proxyConfigOrCallback ( )
298
+ : proxyConfigOrCallback ;
303
299
304
300
proxyMiddleware = getProxyMiddleware ( proxyConfig ) ;
305
301
0 commit comments