Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the --progress option with the serve command #2265

Merged
merged 1 commit into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions packages/serve/__tests__/mergeOptions.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/serve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ServeCommand {
const processors: Array<(opts: Record<string, any>) => void> = [];

for (const optionName in options) {
if (optionName === 'hot' || optionName === 'progress') {
if (optionName === 'hot') {
devServerOptions[optionName] = options[optionName];
webpackOptions[optionName] = options[optionName];
} else {
Expand Down
24 changes: 0 additions & 24 deletions packages/serve/src/mergeOptions.ts

This file was deleted.

17 changes: 14 additions & 3 deletions packages/serve/src/startDevServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { utils } from 'webpack-cli';

import mergeOptions from './mergeOptions';
import { devServerOptionsType } from './types';

/**
*
Expand Down Expand Up @@ -48,6 +46,19 @@ export default async function startDevServer(compiler, cliOptions, logger): Prom

const servers = [];
const usedPorts: number[] = [];
const mergeOptions = (cliOptions: devServerOptionsType, devServerOptions: devServerOptionsType): devServerOptionsType => {
// CLI options should take precedence over devServer options,
// and CLI options should have no default values included
const options = { ...devServerOptions, ...cliOptions };

if (devServerOptions.client && cliOptions.client) {
// the user could set some client options in their devServer config,
// then also specify client options on the CLI
options.client = { ...devServerOptions.client, ...cliOptions.client };
}

return options;
};

for (const devServerOpts of devServerOptions) {
const options = mergeOptions(cliOptions, devServerOpts);
Expand Down
16 changes: 16 additions & 0 deletions test/serve/basic/serve-basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ describe('basic serve usage', () => {
expect(stdout).not.toContain('HotModuleReplacementPlugin');
});

it('should work with the "--progress" option', async () => {
const { stderr, stdout } = await runServe(['--progress'], __dirname);

expect(stderr).toContain('webpack.Progress');
expect(stdout).toContain('main.js');
expect(stdout).not.toContain('HotModuleReplacementPlugin');
});

it('should work with the "--progress" option using the "profile" value', async () => {
const { stderr, stdout } = await runServe(['--progress', 'profile'], __dirname);

expect(stderr).toContain('webpack.Progress');
expect(stdout).toContain('main.js');
expect(stdout).not.toContain('HotModuleReplacementPlugin');
});

it('should work with flags', async () => {
const { stderr, stdout } = await runServe(['--hot'], __dirname);

Expand Down