Skip to content

Commit

Permalink
inline css images and fonts
Browse files Browse the repository at this point in the history
closes #786
  • Loading branch information
Fil committed Feb 14, 2024
1 parent 4a75582 commit bfc0468
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ function rewriteInputsNamespace(code: string) {
return code.replace(/\b__ns__\b/g, "inputs-3a86ea");
}

const INLINE_CSS = Object.fromEntries(
["svg", "png", "jpeg", "jpg", "gif", "eot", "otf", "woff", "woff2"].map((ext) => [`.${ext}`, "dataurl" as const])
);
export async function bundleStyles({path, theme}: {path?: string; theme?: string[]}): Promise<string> {
const result = await build({
bundle: true,
loader: INLINE_CSS,
...(path ? {entryPoints: [path]} : {stdin: {contents: renderTheme(theme!), loader: "css"}}),
write: false,
alias: STYLE_MODULES
Expand Down

0 comments on commit bfc0468

Please sign in to comment.