fix: tailwind now respects basepath (#2138)
This commit is contained in:
@@ -9,7 +9,10 @@
|
||||
"preact/": "https://esm.sh/preact@10.15.1/",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.5.0",
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0"
|
||||
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0",
|
||||
"tailwindcss": "npm:tailwindcss@3.3.5",
|
||||
"tailwindcss/": "npm:/tailwindcss@3.3.5/",
|
||||
"tailwindcss/plugin": "npm:/tailwindcss@3.3.5/plugin.js"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from "$fresh/server.ts";
|
||||
import tailwind from "$fresh/plugins/tailwind.ts";
|
||||
|
||||
export default defineConfig({
|
||||
router: { basePath: "/foo/bar" },
|
||||
plugins: [
|
||||
tailwind(),
|
||||
],
|
||||
});
|
||||
@@ -6,5 +6,6 @@
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import config from "./fresh.config.ts";
|
||||
|
||||
await start(manifest, { router: { basePath: "/foo/bar" } });
|
||||
await start(manifest, config);
|
||||
|
||||
@@ -4,7 +4,14 @@ export async function handler(
|
||||
_req: Request,
|
||||
ctx: FreshContext<{ data: string }>,
|
||||
) {
|
||||
ctx.state.data = "it works";
|
||||
if (ctx.url.pathname === "/foo/bar/middleware-only.css") {
|
||||
return new Response(".foo-bar { color: red }", {
|
||||
headers: {
|
||||
"Content-Type": "text/css",
|
||||
},
|
||||
});
|
||||
}
|
||||
ctx.state.data = "middleware is working";
|
||||
const resp = await ctx.next();
|
||||
resp.headers.set("server", "fresh server");
|
||||
return resp;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
export default function Home() {
|
||||
return <h1>it works</h1>;
|
||||
}
|
||||
import { defineRoute } from "$fresh/server.ts";
|
||||
|
||||
export default defineRoute<{ data: string }>((req, ctx) => {
|
||||
return (
|
||||
<>
|
||||
<h1 class="text-red-600 block">it works</h1>
|
||||
{ctx.state.data}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Config } from "tailwindcss";
|
||||
|
||||
export default {
|
||||
content: [
|
||||
"{routes,islands,components}/**/*.{ts,tsx}",
|
||||
],
|
||||
} as Config;
|
||||
Reference in New Issue
Block a user