( code: string, id: string, cleanId: string, deps: string[], config: CssPluginConfig, logger: Logger, isModule: boolean, )
| 376 | } |
| 377 | |
| 378 | async function processWithLightningCSS( |
| 379 | code: string, |
| 380 | id: string, |
| 381 | cleanId: string, |
| 382 | deps: string[], |
| 383 | config: CssPluginConfig, |
| 384 | logger: Logger, |
| 385 | isModule: boolean, |
| 386 | ): Promise<ProcessResult> { |
| 387 | const lang = getPreprocessorLangFromId(id) |
| 388 | const cssModules = resolveCssModulesConfig( |
| 389 | config.css.modules, |
| 390 | isModule, |
| 391 | logger, |
| 392 | ) |
| 393 | |
| 394 | if (lang) { |
| 395 | const preResult = await compilePreprocessor( |
| 396 | lang, |
| 397 | code, |
| 398 | cleanId, |
| 399 | config.css.preprocessorOptions, |
| 400 | ) |
| 401 | deps.push(...preResult.deps) |
| 402 | |
| 403 | return transformWithLightningCSS(preResult.code, cleanId, { |
| 404 | target: config.css.target, |
| 405 | lightningcss: config.css.lightningcss, |
| 406 | minify: config.css.minify, |
| 407 | cssModules, |
| 408 | sourceMap: config.sourceMap, |
| 409 | }) |
| 410 | } |
| 411 | |
| 412 | // Virtual modules (with query strings) can't use file-based bundling; |
| 413 | // ?inline is excluded because the underlying file is real. |
| 414 | if (id !== cleanId && !RE_INLINE.test(id)) { |
| 415 | return transformWithLightningCSS(code, cleanId, { |
| 416 | target: config.css.target, |
| 417 | lightningcss: config.css.lightningcss, |
| 418 | minify: config.css.minify, |
| 419 | cssModules, |
| 420 | sourceMap: config.sourceMap, |
| 421 | }) |
| 422 | } |
| 423 | |
| 424 | if (RE_CSS.test(cleanId)) { |
| 425 | const bundleResult = await bundleWithLightningCSS( |
| 426 | cleanId, |
| 427 | { |
| 428 | target: config.css.target, |
| 429 | lightningcss: config.css.lightningcss, |
| 430 | minify: config.css.minify, |
| 431 | cssModules, |
| 432 | preprocessorOptions: config.css.preprocessorOptions, |
| 433 | sourceMap: config.sourceMap, |
| 434 | logger, |
| 435 | }, |
no test coverage detected