fix(core): restore Rspack ProgressBar colors (#10632)

This commit is contained in:
Sébastien Lorber 2024-10-31 12:54:36 +01:00 committed by GitHub
parent 5cf2c39836
commit fce0884768
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 8 deletions

View file

@ -87,17 +87,19 @@ export async function getProgressBarPlugin({
currentBundler: CurrentBundler;
}): Promise<typeof WebpackBar> {
if (currentBundler.name === 'rspack') {
class CustomRspackProgressPlugin extends currentBundler.instance
.ProgressPlugin {
constructor({name}: {name: string}) {
// TODO add support for color
// Unfortunately the rspack.ProgressPlugin does not have a name option
const rspack = getCurrentBundlerAsRspack({currentBundler});
class CustomRspackProgressPlugin extends rspack.ProgressPlugin {
constructor({name, color = 'green'}: {name?: string; color?: string}) {
// Unfortunately rspack.ProgressPlugin does not have name/color options
// See https://rspack.dev/plugins/webpack/progress-plugin
// @ts-expect-error: adapt Rspack ProgressPlugin constructor
super({prefix: name});
super({
prefix: name,
template: `● {prefix:.bold} {bar:50.${color}/white.dim} ({percent}%) {wide_msg:.dim}`,
progressChars: '■■',
});
}
}
return CustomRspackProgressPlugin as typeof WebpackBar;
return CustomRspackProgressPlugin as unknown as typeof WebpackBar;
}
return WebpackBar;

View file

@ -65,6 +65,7 @@ async function createBaseClientConfig({
new ChunkAssetPlugin(),
new ProgressBarPlugin({
name: 'Client',
color: 'green',
}),
await createStaticDirectoriesCopyPlugin({
props,