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

Function loadPreprocessorPath

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

Source from the content-addressed store, hash-verified

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