Skip to content

Commit bf4193a

Browse files
committed
replaceAll
1 parent 5be11d3 commit bf4193a

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/plugin-vite/src/plugins/server_snapshot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ export default ${JSON.stringify(route.css)}
532532
const content = await Deno.readTextFile(filePath);
533533
if (!content.includes(`["__FRESH_CSS_PLACEHOLDER__"]`)) continue;
534534

535-
const replaced = content.replace(
535+
// Replace all placeholders in the file with the CSS
536+
const replaced = content.replaceAll(
536537
`["__FRESH_CSS_PLACEHOLDER__"]`,
537538
info.css
538539
? JSON.stringify(info.css.map((css) => `/${css}`))

packages/plugin-vite/tests/build_test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,19 @@ integrationTest("vite build - route css import", async () => {
464464
);
465465
});
466466

467+
integrationTest(
468+
"vite build - __FRESH_CSS_PLACEHOLDER__ has been replaced",
469+
async () => {
470+
await using res = await buildVite(DEMO_DIR, { base: "/my-app/" });
471+
472+
const serverEntryJs = await Deno.readTextFile(
473+
path.join(res.tmp, "_fresh", "server", "server-entry.mjs"),
474+
);
475+
476+
expect(serverEntryJs).not.toContain("__FRESH_CSS_PLACEHOLDER__");
477+
},
478+
);
479+
467480
integrationTest("vite build - remote island", async () => {
468481
const fixture = path.join(FIXTURE_DIR, "remote_island");
469482
await using res = await buildVite(fixture);

0 commit comments

Comments
 (0)