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

fix(css): enhance error message for missing preprocessor dependency #11485

Merged
merged 7 commits into from Jul 31, 2023
10 changes: 9 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -1504,8 +1504,16 @@ function loadPreprocessor(
return (loadedPreprocessors[lang] = _require(resolved))
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
const preprocessorPackage = {
[PreprocessLang.scss]: 'sass',
[PreprocessLang.sass]: 'sass',
[PreprocessLang.less]: 'less',
[PreprocessLang.styl]: 'stylus',
[PreprocessLang.stylus]: 'stylus',
[PostCssDialectLang.sss]: 'sugarss',
}
throw new Error(
`Preprocessor dependency "${lang}" not found. Did you install it?`,
`Preprocessor dependency "${lang}" not found. Did you install it? Try \`npm i -D ${preprocessorPackage[lang]}\`.`,
EastSun5566 marked this conversation as resolved.
Show resolved Hide resolved
)
} else {
const message = new Error(
Expand Down