( ctx: ExternalAssetContext, document: Document, referrerAbsDir: string, entryPath: string, )
| 264 | } |
| 265 | |
| 266 | function rewriteStyleBlocks( |
| 267 | ctx: ExternalAssetContext, |
| 268 | document: Document, |
| 269 | referrerAbsDir: string, |
| 270 | entryPath: string, |
| 271 | ): boolean { |
| 272 | let modified = false; |
| 273 | for (const styleEl of document.querySelectorAll("style")) { |
| 274 | const css = styleEl.textContent || ""; |
| 275 | if (!css.includes("url(")) continue; |
| 276 | const result = rewriteCssUrls(ctx, css, referrerAbsDir, entryPath); |
| 277 | if (result.modified) { |
| 278 | styleEl.textContent = result.css; |
| 279 | modified = true; |
| 280 | } |
| 281 | } |
| 282 | for (const el of document.querySelectorAll("[style]")) { |
| 283 | const style = el.getAttribute("style") || ""; |
| 284 | if (!style.includes("url(")) continue; |
| 285 | const result = rewriteCssUrls(ctx, style, referrerAbsDir, entryPath); |
| 286 | if (result.modified) { |
| 287 | el.setAttribute("style", result.css); |
| 288 | modified = true; |
| 289 | } |
| 290 | } |
| 291 | return modified; |
| 292 | } |
| 293 | |
| 294 | function localizeHtmlEntry(ctx: ExternalAssetContext, entryPath: string, content: Buffer): void { |
| 295 | const referrerAbsDir = resolve(ctx.absProjectDir, dirname(entryPath)); |
no test coverage detected