Skip to content

Commit

Permalink
add cli support
Browse files Browse the repository at this point in the history
  • Loading branch information
EslamHiko committed May 14, 2019
1 parent 7f47bb7 commit 2d8c08d
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/utils/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ function createConfig(config, argv, { port }) {
options.hotOnly = argv.hotOnly;
}

if (!options.liveReload) {
options.liveReload = argv.liveReload;
}

// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
// We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
if (!options.clientLogLevel && argv.clientLogLevel) {
Expand Down
24 changes: 24 additions & 0 deletions test/CreateConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const argv = {
hot: true,
// Can be `--no-hot-only` in CLI (misleading and undocumented)
hotOnly: false,
// Can be `--live-reload` in CLI (misleading and undocumented)
liveReload: true,
};

describe('createConfig', () => {
Expand Down Expand Up @@ -346,6 +348,28 @@ describe('createConfig', () => {
expect(config).toMatchSnapshot();
});

it('liveReload option', () => {
const config = createConfig(
webpackConfig,
Object.assign({}, argv, { liveReload: true }),
{ port: 8080 }
);

expect(config).toMatchSnapshot();
});

it('liveReload option (in devServer config)', () => {
const config = createConfig(
Object.assign({}, webpackConfig, {
devServer: { liveReload: true },
}),
argv,
{ port: 8080 }
);

expect(config).toMatchSnapshot();
});

it('hot option (in devServer config)', () => {
const config = createConfig(
Object.assign({}, webpackConfig, {
Expand Down

0 comments on commit 2d8c08d

Please sign in to comment.