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

feat: hint more unknown file types #4274

Merged
merged 1 commit into from
Dec 25, 2024
Merged
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
56 changes: 39 additions & 17 deletions packages/core/src/helpers/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,45 @@ function hintUnknownFiles(message: string): string {
return message;
}

if (/File: .+\.s(c|a)ss/.test(message)) {
return message.replace(
hint,
`To enable support for Sass, use "${color.yellow('@rsbuild/plugin-sass')}".`,
);
}
if (/File: .+\.less/.test(message)) {
return message.replace(
hint,
`To enable support for Less, use "${color.yellow('@rsbuild/plugin-less')}".`,
);
}
if (/File: .+\.styl(us)?/.test(message)) {
return message.replace(
hint,
`To enable support for Stylus, use "${color.yellow('@rsbuild/plugin-stylus')}".`,
);
const recommendPlugins = [
{
test: /File: .+\.s(c|a)ss/,
hint: `To enable support for Sass, use "${color.yellow('@rsbuild/plugin-sass')}".`,
},
{
test: /File: .+\.less/,
hint: `To enable support for Less, use "${color.yellow('@rsbuild/plugin-less')}".`,
},
{
test: /File: .+\.styl(us)?/,
hint: `To enable support for Stylus, use "${color.yellow('@rsbuild/plugin-stylus')}".`,
},
{
test: /File: .+\.vue?/,
hint: `To enable support for Vue, use "${color.yellow('@rsbuild/plugin-vue')}".`,
},
{
test: /File: .+\.svelte?/,
hint: `To enable support for Svelte, use "${color.yellow('@rsbuild/plugin-svelte')}".`,
},
{
test: /File: .+\.mdx/,
hint: `To enable support for MDX, use "${color.yellow('@rsbuild/plugin-mdx')}".`,
},
{
test: /File: .+\.toml/,
hint: `To enable support for TOML, use "${color.yellow('@rsbuild/plugin-toml')}".`,
},
{
test: /File: .+\.yaml/,
hint: `To enable support for YAML, use "${color.yellow('@rsbuild/plugin-yaml')}".`,
},
];

for (const plugin of recommendPlugins) {
if (plugin.test.test(message)) {
return message.replace(hint, plugin.hint);
}
}

return message;
Expand Down
Loading