Skip to content

Commit

Permalink
fix: resolve dev server hot options correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Nov 2, 2020
1 parent 4306c4f commit 5a2eb2b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/serve/src/createConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { devServerOptionsType } from './types';
// eslint-disable-next-line node/no-extraneous-import
import { version } from 'webpack-dev-server/package.json';

const isDevServer4 = version.startsWith('4');

/**
*
Expand All @@ -18,10 +22,18 @@ export default function createConfig(args): devServerOptionsType {
// clientLogging is not a valid devServer option
delete options.clientLogging;
}

// only apply hotOnly when both are supplied
if (options.hot && options.hotOnly) {
delete options.hot;
if (isDevServer4) {
if (options.hotOnly) {
options.hot = 'only';
// hotOnly is not a valid devServer option
delete options.hotOnly;
}
} else {
// only apply hotOnly when both are supplied
if (options.hot && options.hotOnly) {
delete options.hot;
}
}

return options;
}

0 comments on commit 5a2eb2b

Please sign in to comment.