react-styleguidist
react-styleguidist copied to clipboard
Webpack "devServer.*" options unable to be customized
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:
https://github.com/styleguidist/react-styleguidist/blob/a460fcc3d6a674146cd74b53362058e17e9aea7e/src/scripts/create-server.ts#L36-L39
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.