fix: support optional static, routes and island dir in vite plugin (#3206)

This commit is contained in:
Marvin Hagemeister
2025-08-08 09:23:38 +02:00
committed by GitHub
parent 0664476e46
commit 22ebb2dbfa
12 changed files with 187 additions and 36 deletions
+71 -4
View File
@@ -4,12 +4,13 @@ import {
withBrowser,
withChildProcessServer,
} from "../../fresh/tests/test_utils.tsx";
import { buildVite } from "./test_utils.ts";
import { buildVite, DEMO_DIR, FIXTURE_DIR } from "./test_utils.ts";
import * as path from "@std/path";
Deno.test({
name: "vite build - launches",
fn: async () => {
await using res = await buildVite();
await using res = await buildVite(DEMO_DIR);
await withChildProcessServer(
{
@@ -30,7 +31,7 @@ Deno.test({
Deno.test({
name: "vite build - serves static files",
fn: async () => {
await using viteResult = await buildVite();
await using viteResult = await buildVite(DEMO_DIR);
await withChildProcessServer(
{
@@ -51,7 +52,7 @@ Deno.test({
Deno.test({
name: "vite build - loads islands",
fn: async () => {
await using res = await buildVite();
await using res = await buildVite(DEMO_DIR);
await withChildProcessServer(
{
@@ -75,3 +76,69 @@ Deno.test({
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "vite build - without static/ dir",
fn: async () => {
const fixture = path.join(FIXTURE_DIR, "no_static");
await using res = await buildVite(fixture);
await withChildProcessServer(
{
cwd: res.tmp,
args: ["serve", "-A", "--port", "0", "_fresh/server.js"],
},
async (address) => {
const res = await fetch(`${address}/ok`);
const text = await res.text();
expect(text).toEqual("ok");
},
);
},
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "vite build - without islands/ dir",
fn: async () => {
const fixture = path.join(FIXTURE_DIR, "no_islands");
await using res = await buildVite(fixture);
await withChildProcessServer(
{
cwd: res.tmp,
args: ["serve", "-A", "--port", "0", "_fresh/server.js"],
},
async (address) => {
const res = await fetch(`${address}`);
const text = await res.text();
expect(text).toContain("ok");
},
);
},
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "vite build - without routes/ dir",
fn: async () => {
const fixture = path.join(FIXTURE_DIR, "no_routes");
await using res = await buildVite(fixture);
await withChildProcessServer(
{
cwd: res.tmp,
args: ["serve", "-A", "--port", "0", "_fresh/server.js"],
},
async (address) => {
const res = await fetch(`${address}`);
const text = await res.text();
expect(text).toEqual("ok");
},
);
},
sanitizeOps: false,
sanitizeResources: false,
});