fix: twind duplicating css when className is used (#1658)

This commit is contained in:
Marvin Hagemeister
2023-08-17 13:01:42 +02:00
committed by GitHub
parent 69b6a8adf2
commit 6d5744861e
11 changed files with 172 additions and 4 deletions
+20
View File
@@ -0,0 +1,20 @@
{
"lock": false,
"tasks": {
"start": "deno run -A --watch=static/,routes/ dev.ts"
},
"imports": {
"$fresh/": "../../",
"twind": "https://esm.sh/twind@0.16.19",
"twind/": "https://esm.sh/twind@0.16.19/",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.2.3"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
+19
View File
@@ -0,0 +1,19 @@
// DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/_app.tsx";
import * as $1 from "./routes/app_class.tsx";
import * as $2 from "./routes/index.tsx";
const manifest = {
routes: {
"./routes/_app.tsx": $0,
"./routes/app_class.tsx": $1,
"./routes/index.tsx": $2,
},
islands: {},
baseUrl: import.meta.url,
};
export default manifest;
+18
View File
@@ -0,0 +1,18 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import twind from "$fresh/plugins/twind.ts";
import twindV1 from "$fresh/plugins/twindv1.ts";
import manifest from "./fresh.gen.ts";
const twindPlugin = Deno.env.has("TWIND_V1")
? twindV1({
selfURL: import.meta.url,
// deno-lint-ignore no-explicit-any
} as any)
: twind({ selfURL: import.meta.url });
await start(manifest, { plugins: [twindPlugin] });
+16
View File
@@ -0,0 +1,16 @@
import { AppProps } from "$fresh/server.ts";
export default function App({ Component }: AppProps) {
return (
<html className="bg-slate-800">
<head className="bg-slate-800">
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>fresh-foo</title>
</head>
<body className="bg-slate-800">
<Component />
</body>
</html>
);
}
@@ -0,0 +1,3 @@
export default function Page() {
return <h1>it works</h1>;
}
+27
View File
@@ -0,0 +1,27 @@
import * as path from "https://deno.land/std@0.192.0/path/mod.ts";
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
const links: string[] = [];
for (const file of Deno.readDirSync(__dirname)) {
if (file.name.startsWith("index")) continue;
const name = path.basename(file.name, path.extname(file.name));
links.push(name);
}
export default function Home() {
return (
<div class="mx-auto max-w-md">
<h1 class="text-3xl font-bold my-8">Tests</h1>
<ul class="pl-4">
{links.map((link) => {
return (
<li key={link} class="list-disc">
<a href={`/${link}`} class="underline">{link}</a>
</li>
);
})}
</ul>
</div>
);
}