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

Webpack "devServer.*" options unable to be customized #2033

Closed
dannobytes opened this issue Sep 16, 2022 · 0 comments · Fixed by #2034
Closed

Webpack "devServer.*" options unable to be customized #2033

dannobytes opened this issue Sep 16, 2022 · 0 comments · Fixed by #2034

Comments

@dannobytes
Copy link
Contributor

dannobytes commented Sep 16, 2022

Current behavior

After upgrading to v12, webpack@5 now by default enables the devServer.client.overlay option, which shows a blocking modal whenever a compilation warning or error occurs. This is very obstructive, and we should be able to easily modify this by overriding the option. In addition, progress is disabled, and we should be able to turn this on.

// styleguide.config.js
{
  ...,
  webpackConfig: {
    devServer: {
      // Turn overlays off. Enable progress indicator.
      client: { overlay: false, progress: true },
    },
  }
}

However, these configs are not making their way to the webpack dev server. I tracked it down to the sequence of how the internal webpack dev config was being shallowly merged:

const webpackDevServerConfig: Configuration = {
...webpackConfig.devServer,
...baseConfig,
};

Because the baseConfig contains a client field, it's always overwriting what's being passed through from ...webpackConfig.devServer.

Solution

A simple fix would be reorder this to ensure the baseConfig is applied first, while merging onto it the webpackConfig.devServer, e.g.

	const webpackDevServerConfig: Configuration = {
		...baseConfig,
		...webpackConfig.devServer,
	};

This would ensure our options from the styleguide.config file were being passed through.

Expected behavior

When overriding webpack.devServer.client options, they should be passed through so I can enable progress and/or turn off overlays.

dannobytes added a commit to dannobytes/react-styleguidist that referenced this issue Sep 16, 2022
When a custom `webpackConfig.devServer.client` option is set, they are
currently being overridden by the `baseConfig.client` field.

Ensure that field is extendible by consumers while also ensuring the
base config values stay fixed.

styleguidist#2033
@dannobytes dannobytes changed the title Webpack "devServer.client" unable to be customized Webpack "devServer.*" options unable to be customized Sep 19, 2022
ThomasRoest pushed a commit that referenced this issue Oct 6, 2022
* fix: ensure devserver client options are configurable

When a custom `webpackConfig.devServer.client` option is set, they are
currently being overridden by the `baseConfig.client` field.

Ensure that field is extendible by consumers while also ensuring the
base config values stay fixed.

#2033

* fix: ensure all devServer options are overridable; add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant