Skip to content

Commit

Permalink
fix(core): restore Rspack ProgressBar colors (#10632)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Oct 31, 2024
1 parent 5cf2c39 commit fce0884
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/docusaurus-bundler/src/currentBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/src/webpack/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async function createBaseClientConfig({
new ChunkAssetPlugin(),
new ProgressBarPlugin({
name: 'Client',
color: 'green',
}),
await createStaticDirectoriesCopyPlugin({
props,
Expand Down

0 comments on commit fce0884

Please sign in to comment.