Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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
Original file line number Diff line number Diff line change
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]}\`.`,
)
} else {
const message = new Error(
Expand Down