Created
November 12, 2023 07:30
-
-
Save podhmo/b473fde42d857114a21fd2f5386ace3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h, Fragment } from 'preact'; | |
import { useState} from 'preact/hooks'; | |
import type { ComponentChildren } from 'preact'; | |
export const App = () => { | |
const [count, setCount] = useState(0); | |
return (<> | |
<h1>hello</h1> | |
<button onClick={() => setCount(() => count + 1)}>click me { count }</button> | |
</>); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>preact sandbox</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- css --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css"> | |
<script type="importmap"> | |
{ | |
"imports": { | |
"preact": "https://esm.sh/preact@10.18.1", | |
"preact/": "https://esm.sh/preact@10.18.1/", | |
"./dist/": "./dist/" | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<div class="container"> | |
<div id="app"></div> | |
</div> | |
<script type="module"> | |
import { h, Component, render } from "preact"; | |
let appName = "00app.js"; | |
if (location.search.includes("app=")) { | |
appName = new URLSearchParams(location.search).get("app"); | |
} | |
const { App } = await import(`./dist/${appName}`) | |
render(h(App, null, null), document.querySelector("#app")); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL = bash | |
serve: | |
esbuild --serve=8080 --servedir=. --outdir=dist *.tsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"lib": [ | |
"es2022", | |
"dom" | |
], | |
"jsxFactory": "h", | |
"jsxFragmentFactory": "Fragment", | |
"jsx": "preserve" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment