diff --git a/deno.json b/deno.json index 6ccafe7..137c482 100644 --- a/deno.json +++ b/deno.json @@ -3,9 +3,10 @@ "deno.window", "DOM" ]}, "imports": { - "react-original": "https://esm.sh/preact@10.13.2/compat", "react": "https://esm.sh/preact@10.13.2/compat", - "@eno/app": "./dummy-app.tsx" + + "react-original": "https://esm.sh/preact@10.13.2/compat", + "@eno/app": "./example/app.tsx" }, "tasks": { diff --git a/dummy-app.tsx b/dummy-app.tsx deleted file mode 100644 index 70c39dc..0000000 --- a/dummy-app.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import React from "react"; - -export default ()=>
dummy app
\ No newline at end of file diff --git a/example/app.tsx b/example/app.tsx index fd1825c..4de6dc2 100644 --- a/example/app.tsx +++ b/example/app.tsx @@ -1,11 +1,19 @@ +import TWPreTail from "https://esm.sh/@twind/preset-tailwind@1.1.4"; +import TWPreAuto from "https://esm.sh/@twind/preset-autoprefix@1.0.7"; import React from "react"; import Component from "./deep/component.tsx"; -export default ()=>{ +export default ()=> +{ const [countGet, countSet] = React.useState(1); -return
-

Title!!

-

subtitle

- -
; -}; \ No newline at end of file + return
+

Title!!

+

subtitle

+ +
; +}; + +export const CSS = { + presets: [TWPreTail(), TWPreAuto()], + hash:false +}; diff --git a/server.tsx b/server.tsx index 2ecf332..ad62492 100644 --- a/server.tsx +++ b/server.tsx @@ -1,7 +1,7 @@ import * as ESBuild from 'https://deno.land/x/esbuild@v0.14.45/mod.js'; import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts"; import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts"; -import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2/deno/preact-render-to-string.mjs"; +import SSR from "https://esm.sh/v113/preact-render-to-string@6.0.2"; import React, {createElement as h} from "react"; const Transpiled = new Map(); @@ -127,7 +127,10 @@ catch(e) console.log(`deno.json not found`); } -const App = await import("@eno/app"); +import {default as App, CSS} from "@eno/app"; +import * as Twind from "https://esm.sh/@twind/core@1.1.3"; +const TwindInst = Twind.install(CSS); + Deno.serve({ port: 3000 }, async(_req:Request) => { @@ -220,34 +223,25 @@ FileListen("${url.pathname}", reloadHandler);`; } else { + const results = Twind.extract(SSR(), TwindInst); + type = `text/html`; body = ` + -
${SSR()}
+
${results.html}
`;