(url, importer)
| 376 | idResolver(environment, url, importer) |
| 377 | |
| 378 | const urlResolver: CssUrlResolver = async (url, importer) => { |
| 379 | const decodedUrl = decodeURI(url) |
| 380 | if (checkPublicFile(decodedUrl, config)) { |
| 381 | if (encodePublicUrlsInCSS(config)) { |
| 382 | return [publicFileToBuiltUrl(decodedUrl, config), undefined] |
| 383 | } else { |
| 384 | const base = joinUrlSegments( |
| 385 | config.server.origin ?? '', |
| 386 | config.base, |
| 387 | ) |
| 388 | return [joinUrlSegments(base, decodedUrl), undefined] |
| 389 | } |
| 390 | } |
| 391 | const [id, fragment] = decodedUrl.split('#') |
| 392 | let resolved = await resolveUrl(id, importer) |
| 393 | if (resolved) { |
| 394 | if (fragment) resolved += '#' + fragment |
| 395 | let url = await fileToUrl(this, resolved) |
| 396 | // Inherit HMR timestamp if this asset was invalidated |
| 397 | if (!url.startsWith('data:') && this.environment.mode === 'dev') { |
| 398 | const mod = [ |
| 399 | ...(this.environment.moduleGraph.getModulesByFile(resolved) ?? |
| 400 | []), |
| 401 | ].find((mod) => mod.type === 'asset') |
| 402 | if (mod?.lastHMRTimestamp) { |
| 403 | url = injectQuery(url, `t=${mod.lastHMRTimestamp}`) |
| 404 | } |
| 405 | } |
| 406 | return [url, cleanUrl(resolved)] |
| 407 | } |
| 408 | if (config.command === 'build') { |
| 409 | const isExternal = config.build.rolldownOptions.external |
| 410 | ? resolveUserExternal( |
| 411 | config.build.rolldownOptions.external, |
| 412 | decodedUrl, // use URL as id since id could not be resolved |
| 413 | id, |
| 414 | false, |
| 415 | ) |
| 416 | : false |
| 417 | |
| 418 | if (!isExternal) { |
| 419 | // #9800 If we cannot resolve the css url, leave a warning. |
| 420 | config.logger.warnOnce( |
| 421 | `\n${decodedUrl} referenced in ${id} didn't resolve at build time, it will remain unchanged to be resolved at runtime`, |
| 422 | ) |
| 423 | } |
| 424 | } |
| 425 | return [url, undefined] |
| 426 | } |
| 427 | |
| 428 | const { |
| 429 | code: css, |
no test coverage detected