Skip to content

Commit

Permalink
fix: allow preprocessor to be installed outside of the root directory (
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts authored and aleclarson committed Nov 8, 2021
1 parent 0de88b0 commit ded48d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -942,7 +942,10 @@ function loadPreprocessor(lang: PreprocessLang, root: string): any {
return loadedPreprocessors[lang]
}
try {
const resolved = require.resolve(lang, { paths: [root] })
// Search for the preprocessor in the root directory first, and fall back
// to the default require paths.
const fallbackPaths = require.resolve.paths(lang) || []
const resolved = require.resolve(lang, { paths: [root, ...fallbackPaths] })
return (loadedPreprocessors[lang] = require(resolved))
} catch (e) {
throw new Error(
Expand Down

0 comments on commit ded48d2

Please sign in to comment.