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

Function read

packages/vite/src/node/plugins/css.ts:3244–3270  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

3242 projectRoot: config.root,
3243 resolver: {
3244 async read(filePath) {
3245 if (filePath === filename) {
3246 return src
3247 }
3248
3249 const code = fs.readFileSync(filePath, 'utf-8')
3250 const lang = CSS_LANGS_RE.exec(filePath)?.[1] as
3251 | CssLang
3252 | undefined
3253 if (isPreProcessor(lang)) {
3254 const result = await compileCSSPreprocessors(
3255 environment,
3256 id,
3257 lang,
3258 code,
3259 workerController,
3260 )
3261 result.deps?.forEach((dep) => deps.add(dep))
3262 // TODO: support source map
3263 return result.code
3264 } else if (lang === 'sss') {
3265 const sssResult = await transformSugarSS(environment, id, code)
3266 // TODO: support source map
3267 return sssResult.code
3268 }
3269 return code
3270 },
3271 async resolve(id, from) {
3272 const publicFile = checkPublicFile(
3273 id,

Callers

nothing calls this directly

Calls 4

isPreProcessorFunction · 0.85
compileCSSPreprocessorsFunction · 0.85
transformSugarSSFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected