Skip to content

Commit

Permalink
feat: minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Jul 13, 2019
1 parent d3da508 commit 9a4fafb
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions lib/Server.js
Expand Up @@ -66,22 +66,8 @@ class Server {

this.log = _log || createLogger(options);

// set serverMode default
if (this.options.serverMode === undefined) {
this.options.serverMode = 'sockjs';
} else {
this.log.warn(
'serverMode is an experimental option, meaning its usage could potentially change without warning'
);
}
// set clientMode default
if (this.options.clientMode === undefined) {
this.options.clientMode = 'sockjs';
} else {
this.log.warn(
'clientMode is an experimental option, meaning its usage could potentially change without warning'
);
}
// set client and server default mode
this.setDefaultMode();

updateCompiler(this.compiler, this.options);

Expand Down Expand Up @@ -153,6 +139,18 @@ class Server {
}, this);
}

setDefaultMode() {
['serverMode', 'clientMode'].forEach((mode) => {
if (this.options[mode] === undefined) {
this.options[mode] = 'sockjs';
} else {
this.log.warn(
`${mode} is an experimental option, meaning its usage could potentially change without warning`
);
}
});
}

setupProgressPlugin() {
// for CLI output
new webpack.ProgressPlugin({
Expand Down Expand Up @@ -292,14 +290,12 @@ class Server {
* ]
*/
this.options.proxy.forEach((proxyConfigOrCallback) => {
let proxyConfig;
let proxyMiddleware;

if (typeof proxyConfigOrCallback === 'function') {
proxyConfig = proxyConfigOrCallback();
} else {
proxyConfig = proxyConfigOrCallback;
}
let proxyConfig =
typeof proxyConfigOrCallback === 'function'
? proxyConfigOrCallback()
: proxyConfigOrCallback;

proxyMiddleware = getProxyMiddleware(proxyConfig);

Expand Down

0 comments on commit 9a4fafb

Please sign in to comment.