MCPcopy
hub / github.com/vitejs/vite / loadPreprocessorPath

Function loadPreprocessorPath

packages/vite/src/node/plugins/css.ts:2423–2443  ·  view source on GitHub ↗
(
  lang: PreprocessLang | PostCssDialectLang | 'sass-embedded',
  root: string,
)

Source from the content-addressed store, hash-verified

2421> = {}
2422
2423function loadPreprocessorPath(
2424 lang: PreprocessLang | PostCssDialectLang | 'sass-embedded',
2425 root: string,
2426): string {
2427 const cached = loadedPreprocessorPath[lang]
2428 if (cached) {
2429 return cached
2430 }
2431
2432 // Try resolve from project root first, then the current vite installation path
2433 const resolved =
2434 nodeResolveWithVite(lang, undefined, { root }) ??
2435 nodeResolveWithVite(lang, _dirname, { root })
2436 if (resolved) return (loadedPreprocessorPath[lang] = resolved)
2437
2438 // Error if we can't find the preprocessor
2439 const installCommand = getPackageManagerCommand('install')
2440 throw new Error(
2441 `Preprocessor dependency "${lang}" not found. Did you install it? Try \`${installCommand} -D ${lang}\`.`,
2442 )
2443}
2444
2445function loadSassPackage(
2446 root: string,

Callers 3

loadSassPackageFunction · 0.85
loadSssFunction · 0.85
processFunction · 0.85

Calls 2

nodeResolveWithViteFunction · 0.90
getPackageManagerCommandFunction · 0.90

Tested by

no test coverage detected