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: ensure devserver client options are configurable #2034

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/scripts/__tests__/create-server.spec.ts
Expand Up @@ -61,3 +61,47 @@ test('createServer should return an object containing a development Webpack comp
expect(output.chunkFilename).toBe('build/[name].js');
done();
});

test('createServer should apply some base config options', () => {
process.chdir('test/apps/basic');
const config = {
...getConfig(),
serverHost: 'localhost',
serverPort: 6000,
};
const result = createServer(config, 'development');
expect(result).toBeTruthy();
expect(result.compiler).toBeTruthy();
expect(result.compiler.options.devServer).toMatchObject({
host: 'localhost',
port: 6000,
compress: true,
hot: true,
client: { logging: 'none' },
webSocketServer: 'ws',
});
});

test('createServer should allow overriding default devServer options', () => {
process.chdir('test/apps/basic');
const config = {
...getConfig(),
webpackConfig: {
devServer: {
client: {
overlay: false,
progress: true,
},
},
},
};
const result = createServer(config, 'development');
expect(result).toBeTruthy();
expect(result.compiler).toBeTruthy();
expect(result.compiler.options.devServer).toMatchObject({
client: {
overlay: false,
progress: true,
},
});
});
7 changes: 4 additions & 3 deletions src/scripts/create-server.ts
Expand Up @@ -33,13 +33,14 @@ export default function createServer(
},
};

const webpackDevServerConfig: Configuration = {
...webpackConfig.devServer,
// Allow custom devServer options to override base config.
webpackConfig.devServer = {
...baseConfig,
...webpackConfig.devServer,
ThomasRoest marked this conversation as resolved.
Show resolved Hide resolved
};

const compiler = webpack(webpackConfig);
const devServer = new WebpackDevServer(webpackDevServerConfig, compiler);
const devServer = new WebpackDevServer(webpackConfig.devServer, compiler);

// User defined customizations
if (config.configureServer) {
Expand Down