Skip to content

Refactor use built in colors #2132

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

Merged
merged 2 commits into from
Jul 29, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"strip-ansi": "^6.0.0",
"supertest": "^7.0.0",
"typescript": "^5.3.3",
"webpack": "^5.93.0"
"webpack": "^5.101.0"
},
"peerDependencies": {
"webpack": "^5.0.0"
Expand Down
24 changes: 21 additions & 3 deletions src/utils/setupHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,18 @@ function setupHooks(context) {
childStatsOptions = normalizeStatsOptions(childStatsOptions);

if (typeof childStatsOptions.colors === "undefined") {
const [firstCompiler] =
/** @type {MultiCompiler} */
(compiler).compilers;

// TODO remove `colorette` and set minimum supported webpack version is `5.101.0`
childStatsOptions.colors =
require("colorette").isColorSupported;
typeof firstCompiler.webpack !== "undefined" &&
typeof firstCompiler.webpack.cli !== "undefined" &&
typeof firstCompiler.webpack.cli.isColorSupported ===
"function"
? firstCompiler.webpack.cli.isColorSupported()
: require("colorette").isColorSupported;
}

return childStatsOptions;
Expand All @@ -122,12 +132,20 @@ function setupHooks(context) {
);

if (typeof statsOptions.colors === "undefined") {
statsOptions.colors = require("colorette").isColorSupported;
const { compiler } = /** @type {{ compiler: Compiler }} */ (context);
// TODO remove `colorette` and set minimum supported webpack version is `5.101.0`
statsOptions.colors =
typeof compiler.webpack !== "undefined" &&
typeof compiler.webpack.cli !== "undefined" &&
typeof compiler.webpack.cli.isColorSupported === "function"
? compiler.webpack.cli.isColorSupported()
: require("colorette").isColorSupported;
}
}

const printedStats = stats.toString(
/** @type {StatsObjectOptions} */ (statsOptions),
/** @type {StatsObjectOptions} */
(statsOptions),
);

// Avoid extra empty line when `stats: 'none'`
Expand Down
Loading