create-vite-hyperapp 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -18
- package/create-vite-hyperapp.mjs +193 -0
- package/package.json +18 -11
- package/templates/{template → common}/_gitignore +1 -1
- package/templates/{template-ts/src → common/src/app}/style.css +0 -4
- package/templates/{template → js-html-cli}/index.html +3 -3
- package/templates/js-html-cli/jsconfig.json +13 -0
- package/templates/js-html-cli/package.json +20 -0
- package/templates/js-html-cli/src/app/counter.js +5 -0
- package/templates/js-html-cli/src/app/logos.js +24 -0
- package/templates/js-html-cli/src/app/main.js +24 -0
- package/templates/{template → js-html-cli}/src/run.js +2 -2
- package/templates/js-html-cli/vite.config.js +12 -0
- package/templates/{template-ssr → js-html-ssr}/index.html +2 -2
- package/templates/js-html-ssr/jsconfig.json +13 -0
- package/templates/js-html-ssr/package.json +25 -0
- package/templates/{template-ssr → js-html-ssr}/server.js +10 -8
- package/templates/js-html-ssr/src/app/counter.js +5 -0
- package/templates/js-html-ssr/src/app/logos.js +24 -0
- package/templates/js-html-ssr/src/app/main.js +24 -0
- package/templates/{template-ssr → js-html-ssr}/src/entry-client.js +2 -2
- package/templates/js-html-ssr/src/entry-server.js +5 -0
- package/templates/js-html-ssr/vite.config.js +13 -0
- package/templates/js-jsx-cli/index.html +13 -0
- package/templates/js-jsx-cli/jsconfig.json +15 -0
- package/templates/{template → js-jsx-cli}/package.json +3 -3
- package/templates/js-jsx-cli/src/app/logos.jsx +15 -0
- package/templates/{template/src → js-jsx-cli/src/app}/main.jsx +1 -13
- package/templates/js-jsx-cli/src/run.js +5 -0
- package/templates/js-jsx-cli/vite.config.js +12 -0
- package/templates/js-jsx-ssr/index.html +13 -0
- package/templates/js-jsx-ssr/jsconfig.json +15 -0
- package/templates/{template-ssr → js-jsx-ssr}/package.json +7 -7
- package/templates/{template-ts-ssr → js-jsx-ssr}/server.js +11 -9
- package/templates/js-jsx-ssr/src/app/logos.jsx +15 -0
- package/templates/{template-ssr/src → js-jsx-ssr/src/app}/main.jsx +1 -13
- package/templates/js-jsx-ssr/src/entry-client.js +5 -0
- package/templates/js-jsx-ssr/src/entry-server.js +5 -0
- package/templates/js-jsx-ssr/vite.config.js +13 -0
- package/templates/js-plain-cli/index.html +13 -0
- package/templates/js-plain-cli/jsconfig.json +13 -0
- package/templates/{template-ts → js-plain-cli}/package.json +4 -5
- package/templates/js-plain-cli/src/app/counter.js +8 -0
- package/templates/js-plain-cli/src/app/logos.js +18 -0
- package/templates/js-plain-cli/src/app/main.js +25 -0
- package/templates/js-plain-cli/src/run.js +5 -0
- package/templates/js-plain-cli/vite.config.js +12 -0
- package/templates/js-plain-ssr/index.html +13 -0
- package/templates/js-plain-ssr/jsconfig.json +13 -0
- package/templates/{template-ts-ssr → js-plain-ssr}/package.json +8 -9
- package/templates/js-plain-ssr/server.js +62 -0
- package/templates/js-plain-ssr/src/app/counter.js +8 -0
- package/templates/js-plain-ssr/src/app/logos.js +18 -0
- package/templates/js-plain-ssr/src/app/main.js +25 -0
- package/templates/js-plain-ssr/src/entry-client.js +5 -0
- package/templates/js-plain-ssr/src/entry-server.js +5 -0
- package/templates/js-plain-ssr/vite.config.js +13 -0
- package/templates/tj-html-cli/index.html +13 -0
- package/templates/tj-html-cli/jsconfig.json +29 -0
- package/templates/tj-html-cli/package.json +21 -0
- package/templates/tj-html-cli/src/app/counter.js +16 -0
- package/templates/tj-html-cli/src/app/logos.js +24 -0
- package/templates/tj-html-cli/src/app/main.js +27 -0
- package/templates/tj-html-cli/src/run.js +5 -0
- package/templates/tj-html-cli/src/types/global.d.ts +13 -0
- package/templates/tj-html-cli/src/types/hyperapp-html.d.ts +101 -0
- package/templates/tj-html-cli/src/types/hyperapp-svg.d.ts +73 -0
- package/templates/tj-html-cli/src/types/hyperapp-tags.d.ts +34 -0
- package/templates/tj-html-cli/vite.config.js +12 -0
- package/templates/tj-html-ssr/index.html +13 -0
- package/templates/tj-html-ssr/jsconfig.json +31 -0
- package/templates/tj-html-ssr/package.json +29 -0
- package/templates/tj-html-ssr/server.js +63 -0
- package/templates/tj-html-ssr/src/app/counter.js +16 -0
- package/templates/tj-html-ssr/src/app/logos.js +24 -0
- package/templates/tj-html-ssr/src/app/main.js +27 -0
- package/templates/tj-html-ssr/src/entry-client.js +5 -0
- package/templates/tj-html-ssr/src/entry-server.js +5 -0
- package/templates/tj-html-ssr/src/types/global.d.ts +13 -0
- package/templates/tj-html-ssr/src/types/hyperapp-html.d.ts +101 -0
- package/templates/tj-html-ssr/src/types/hyperapp-svg.d.ts +73 -0
- package/templates/tj-html-ssr/src/types/hyperapp-tags.d.ts +34 -0
- package/templates/tj-html-ssr/vite.config.js +13 -0
- package/templates/tj-jsx-cli/index.html +13 -0
- package/templates/tj-jsx-cli/jsconfig.json +31 -0
- package/templates/tj-jsx-cli/package.json +19 -0
- package/templates/tj-jsx-cli/src/app/counter.jsx +18 -0
- package/templates/tj-jsx-cli/src/app/logos.jsx +15 -0
- package/templates/tj-jsx-cli/src/app/main.jsx +26 -0
- package/templates/tj-jsx-cli/src/run.js +5 -0
- package/templates/tj-jsx-cli/src/types/global.d.ts +13 -0
- package/templates/tj-jsx-cli/vite.config.js +12 -0
- package/templates/tj-jsx-ssr/index.html +13 -0
- package/templates/tj-jsx-ssr/jsconfig.json +33 -0
- package/templates/tj-jsx-ssr/package.json +27 -0
- package/templates/tj-jsx-ssr/server.js +63 -0
- package/templates/tj-jsx-ssr/src/app/counter.jsx +18 -0
- package/templates/tj-jsx-ssr/src/app/logos.jsx +15 -0
- package/templates/tj-jsx-ssr/src/app/main.jsx +26 -0
- package/templates/tj-jsx-ssr/src/entry-client.js +5 -0
- package/templates/tj-jsx-ssr/src/entry-server.js +5 -0
- package/templates/tj-jsx-ssr/src/types/global.d.ts +13 -0
- package/templates/tj-jsx-ssr/vite.config.js +13 -0
- package/templates/tj-plain-cli/index.html +13 -0
- package/templates/tj-plain-cli/jsconfig.json +29 -0
- package/templates/tj-plain-cli/package.json +19 -0
- package/templates/tj-plain-cli/src/app/counter.js +19 -0
- package/templates/tj-plain-cli/src/app/logos.js +18 -0
- package/templates/tj-plain-cli/src/app/main.js +28 -0
- package/templates/tj-plain-cli/src/run.js +5 -0
- package/templates/tj-plain-cli/src/types/global.d.ts +13 -0
- package/templates/tj-plain-cli/src/types/hyperapp-h.d.ts +37 -0
- package/templates/tj-plain-cli/vite.config.js +12 -0
- package/templates/tj-plain-ssr/index.html +13 -0
- package/templates/tj-plain-ssr/jsconfig.json +31 -0
- package/templates/tj-plain-ssr/package.json +27 -0
- package/templates/tj-plain-ssr/server.js +63 -0
- package/templates/tj-plain-ssr/src/app/counter.js +19 -0
- package/templates/tj-plain-ssr/src/app/logos.js +18 -0
- package/templates/tj-plain-ssr/src/app/main.js +28 -0
- package/templates/tj-plain-ssr/src/entry-client.js +5 -0
- package/templates/tj-plain-ssr/src/entry-server.js +5 -0
- package/templates/tj-plain-ssr/src/types/global.d.ts +13 -0
- package/templates/tj-plain-ssr/src/types/hyperapp-h.d.ts +37 -0
- package/templates/tj-plain-ssr/vite.config.js +13 -0
- package/templates/{template-ts → ts-html-cli}/index.html +3 -3
- package/templates/ts-html-cli/package.json +21 -0
- package/templates/ts-html-cli/src/app/counter.ts +12 -0
- package/templates/ts-html-cli/src/app/logos.ts +33 -0
- package/templates/ts-html-cli/src/app/main.ts +27 -0
- package/templates/{template-ts → ts-html-cli}/src/run.ts +2 -2
- package/templates/ts-html-cli/src/types/hyperapp-html.d.ts +101 -0
- package/templates/ts-html-cli/src/types/hyperapp-svg.d.ts +73 -0
- package/templates/ts-html-cli/src/types/hyperapp-tags.d.ts +34 -0
- package/templates/ts-html-cli/tsconfig.json +27 -0
- package/templates/ts-html-cli/vite.config.ts +12 -0
- package/templates/{template-ts-ssr → ts-html-ssr}/index.html +2 -2
- package/templates/ts-html-ssr/package.json +32 -0
- package/templates/ts-html-ssr/server.ts +63 -0
- package/templates/ts-html-ssr/src/app/counter.ts +12 -0
- package/templates/ts-html-ssr/src/app/logos.ts +33 -0
- package/templates/ts-html-ssr/src/app/main.ts +27 -0
- package/templates/{template-ts-ssr → ts-html-ssr}/src/entry-client.ts +2 -2
- package/templates/ts-html-ssr/src/entry-server.ts +5 -0
- package/templates/ts-html-ssr/src/types/hyperapp-html.d.ts +101 -0
- package/templates/ts-html-ssr/src/types/hyperapp-svg.d.ts +73 -0
- package/templates/ts-html-ssr/src/types/hyperapp-tags.d.ts +34 -0
- package/templates/ts-html-ssr/tsconfig.json +27 -0
- package/templates/ts-html-ssr/vite.config.ts +13 -0
- package/templates/ts-jsx-cli/index.html +13 -0
- package/templates/ts-jsx-cli/package.json +21 -0
- package/templates/ts-jsx-cli/src/app/counter.tsx +14 -0
- package/templates/ts-jsx-cli/src/app/logos.tsx +19 -0
- package/templates/ts-jsx-cli/src/app/main.tsx +26 -0
- package/templates/ts-jsx-cli/src/assets/typescript.svg +1 -0
- package/templates/ts-jsx-cli/src/run.ts +5 -0
- package/templates/{template-ts → ts-jsx-cli}/tsconfig.json +6 -3
- package/templates/ts-jsx-cli/vite.config.ts +12 -0
- package/templates/ts-jsx-ssr/index.html +13 -0
- package/templates/ts-jsx-ssr/package.json +30 -0
- package/templates/ts-jsx-ssr/server.ts +63 -0
- package/templates/ts-jsx-ssr/src/app/counter.tsx +14 -0
- package/templates/ts-jsx-ssr/src/app/logos.tsx +19 -0
- package/templates/ts-jsx-ssr/src/app/main.tsx +26 -0
- package/templates/ts-jsx-ssr/src/assets/typescript.svg +1 -0
- package/templates/ts-jsx-ssr/src/entry-client.ts +5 -0
- package/templates/ts-jsx-ssr/src/entry-server.ts +5 -0
- package/templates/{template-ts-ssr → ts-jsx-ssr}/tsconfig.json +7 -4
- package/templates/ts-jsx-ssr/vite.config.ts +13 -0
- package/templates/ts-plain-cli/index.html +13 -0
- package/templates/ts-plain-cli/package.json +21 -0
- package/templates/ts-plain-cli/src/app/counter.ts +13 -0
- package/templates/ts-plain-cli/src/app/logos.ts +30 -0
- package/templates/ts-plain-cli/src/app/main.ts +27 -0
- package/templates/ts-plain-cli/src/assets/typescript.svg +1 -0
- package/templates/ts-plain-cli/src/run.ts +5 -0
- package/templates/ts-plain-cli/src/types/hyperapp-h.d.ts +37 -0
- package/templates/ts-plain-cli/tsconfig.json +27 -0
- package/templates/ts-plain-cli/vite.config.ts +12 -0
- package/templates/ts-plain-ssr/index.html +13 -0
- package/templates/ts-plain-ssr/package.json +30 -0
- package/templates/ts-plain-ssr/server.ts +63 -0
- package/templates/ts-plain-ssr/src/app/counter.ts +13 -0
- package/templates/ts-plain-ssr/src/app/logos.ts +30 -0
- package/templates/ts-plain-ssr/src/app/main.ts +27 -0
- package/templates/ts-plain-ssr/src/assets/typescript.svg +1 -0
- package/templates/ts-plain-ssr/src/entry-client.ts +5 -0
- package/templates/ts-plain-ssr/src/entry-server.ts +5 -0
- package/templates/ts-plain-ssr/src/types/hyperapp-h.d.ts +37 -0
- package/templates/ts-plain-ssr/tsconfig.json +27 -0
- package/templates/ts-plain-ssr/vite.config.ts +13 -0
- package/index.js +0 -154
- package/templates/template/public/vite.svg +0 -1
- package/templates/template/src/hyperapp.svg +0 -4
- package/templates/template/src/style.css +0 -97
- package/templates/template/vite.config.js +0 -6
- package/templates/template-ssr/_gitignore +0 -24
- package/templates/template-ssr/src/entry-server.js +0 -5
- package/templates/template-ssr/src/style.css +0 -97
- package/templates/template-ssr/vite.config.js +0 -6
- package/templates/template-ts/_gitignore +0 -24
- package/templates/template-ts/public/vite.svg +0 -1
- package/templates/template-ts/src/counter.tsx +0 -14
- package/templates/template-ts/src/hyperapp.svg +0 -4
- package/templates/template-ts/src/main.tsx +0 -43
- package/templates/template-ts/src/vite-env.d.ts +0 -2
- package/templates/template-ts/vite.config.ts +0 -6
- package/templates/template-ts-ssr/_gitignore +0 -24
- package/templates/template-ts-ssr/public/vite.svg +0 -1
- package/templates/template-ts-ssr/src/counter.tsx +0 -14
- package/templates/template-ts-ssr/src/entry-server.ts +0 -5
- package/templates/template-ts-ssr/src/main.tsx +0 -43
- package/templates/template-ts-ssr/src/style.css +0 -97
- package/templates/template-ts-ssr/src/vite-env.d.ts +0 -2
- package/templates/template-ts-ssr/vite.config.ts +0 -6
- /package/templates/{template-ssr/src/hyperapp.svg → common/public/favicon.svg} +0 -0
- /package/templates/{template-ts-ssr/src → common/src/assets}/hyperapp.svg +0 -0
- /package/templates/{template-ssr/public → common/src/assets}/vite.svg +0 -0
- /package/templates/{template-ssr/src → js-jsx-cli/src/app}/counter.jsx +0 -0
- /package/templates/{template/src → js-jsx-ssr/src/app}/counter.jsx +0 -0
- /package/templates/{template-ts-ssr/src → ts-html-cli/src/assets}/typescript.svg +0 -0
- /package/templates/{template-ts/src → ts-html-ssr/src/assets}/typescript.svg +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./style.css"
|
|
2
|
+
import { main, h1, p, text } from "@hyperapp/html"
|
|
3
|
+
import Counter from "./counter"
|
|
4
|
+
import Logos from "./logos"
|
|
5
|
+
|
|
6
|
+
export const init = () => ({
|
|
7
|
+
counter: 0,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const HandleClick = state => ({
|
|
11
|
+
...state,
|
|
12
|
+
counter: state.counter + 1,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const view = state =>
|
|
16
|
+
main({ id: "app" }, [
|
|
17
|
+
h1(text("Vite (SSR) + Hyperapp")),
|
|
18
|
+
...Logos(),
|
|
19
|
+
Counter({ clicks: state.counter, onclick: HandleClick }),
|
|
20
|
+
p(
|
|
21
|
+
{ class: "read-the-docs" },
|
|
22
|
+
text("Click on the Vite & Hyperapp logos to learn more"),
|
|
23
|
+
),
|
|
24
|
+
])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { app } from "hyperapp"
|
|
2
|
-
import { init, view } from "./main"
|
|
2
|
+
import { init, view } from "./app/main"
|
|
3
3
|
const node = document.querySelector("#app")
|
|
4
4
|
if (!node) throw new Error("mountpoint not found")
|
|
5
|
-
|
|
5
|
+
app({ init, view, node })
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
import hyperapp from "vite-plugin-hyperapp"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
base: process.env.BASE || "/",
|
|
7
|
+
plugins: [hyperapp()],
|
|
8
|
+
resolve: {
|
|
9
|
+
alias: {
|
|
10
|
+
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>__PROJECTNAME__</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main id="app"></main>
|
|
11
|
+
<script type="module" src="/src/run.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "__PROJECTNAME__",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"hyperapp": "^2.0.22"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"vite": "^
|
|
16
|
-
"vite-plugin-hyperapp": "^
|
|
15
|
+
"vite": "^8.3.4",
|
|
16
|
+
"vite-plugin-hyperapp": "^2.0.4"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import viteLogo from "@/assets/vite.svg"
|
|
2
|
+
import hyperappLogo from "@/assets/hyperapp.svg"
|
|
3
|
+
|
|
4
|
+
const Logos = () => (
|
|
5
|
+
<>
|
|
6
|
+
<a href="https://vitejs.dev">
|
|
7
|
+
<img src={viteLogo} class="logo" alt="Vite logo" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/jorgebucaran/hyperapp">
|
|
10
|
+
<img src={hyperappLogo} class="logo" alt="Hyperapp logo" />
|
|
11
|
+
</a>
|
|
12
|
+
</>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export default Logos
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "./style.css"
|
|
2
|
-
import
|
|
3
|
-
import viteLogo from "/vite.svg"
|
|
2
|
+
import Logos from "./logos"
|
|
4
3
|
import Counter from "./counter"
|
|
5
4
|
|
|
6
5
|
export const init = () => ({
|
|
@@ -12,17 +11,6 @@ const HandleClick = state => ({
|
|
|
12
11
|
counter: state.counter + 1,
|
|
13
12
|
})
|
|
14
13
|
|
|
15
|
-
const Logos = () => (
|
|
16
|
-
<>
|
|
17
|
-
<a href="https://vitejs.dev">
|
|
18
|
-
<img src={viteLogo} class="logo" alt="Vite logo" />
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://hyperapp.dev/">
|
|
21
|
-
<img src={hyperappLogo} class="logo vanilla" alt="Hyperapp logo" />
|
|
22
|
-
</a>
|
|
23
|
-
</>
|
|
24
|
-
)
|
|
25
|
-
|
|
26
14
|
export const view = state => (
|
|
27
15
|
<main id="app">
|
|
28
16
|
<h1>Vite + Hyperapp</h1>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
import hyperapp from "vite-plugin-hyperapp"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [hyperapp()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>__PROJECTNAME__</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<!--ssr-outlet-->
|
|
11
|
+
<script type="module" src="/src/entry-client.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "__PROJECTNAME__",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "node server",
|
|
7
|
+
"dev": "node server.js",
|
|
8
8
|
"build:client": "vite build --outDir dist/client",
|
|
9
9
|
"build:server": "vite build --outDir dist/server --ssr src/entry-server.js",
|
|
10
10
|
"build": "npm run build:client && npm run build:server",
|
|
11
|
-
"preview": "NODE_ENV=production node server"
|
|
11
|
+
"preview": "NODE_ENV=production node server.js"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"vite": "^
|
|
15
|
-
"vite-plugin-hyperapp": "^1.3.0"
|
|
14
|
+
"vite": "^8.3.4"
|
|
16
15
|
},
|
|
17
16
|
"dependencies": {
|
|
18
|
-
"hyperapp": "^2.0.22",
|
|
19
17
|
"compression": "^1.7.4",
|
|
20
18
|
"express": "^4.19.2",
|
|
21
|
-
"
|
|
19
|
+
"hyperapp": "^2.0.22",
|
|
20
|
+
"sirv": "^2.0.4",
|
|
21
|
+
"vite-plugin-hyperapp": "^2.0.4"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -19,7 +19,6 @@ async function createServer() {
|
|
|
19
19
|
vite = await createServer({
|
|
20
20
|
server: { middlewareMode: true },
|
|
21
21
|
appType: "custom",
|
|
22
|
-
base,
|
|
23
22
|
})
|
|
24
23
|
app.use(vite.middlewares)
|
|
25
24
|
} else {
|
|
@@ -29,26 +28,29 @@ async function createServer() {
|
|
|
29
28
|
app.use(base, sirv("./dist/client", { extensions: [] }))
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
app.use("*", async (req, res) => {
|
|
33
|
-
const url = req.originalUrl
|
|
31
|
+
app.use("*", async (req, res, next) => {
|
|
32
|
+
const url = req.originalUrl
|
|
33
|
+
if (!url.startsWith(base)) return next()
|
|
34
34
|
try {
|
|
35
35
|
let template
|
|
36
36
|
let render
|
|
37
37
|
if (!isProduction) {
|
|
38
|
+
if (!vite) throw new Error("Vite dev server is not initialized")
|
|
38
39
|
// Always read fresh template in development
|
|
39
40
|
template = await fs.readFile("./index.html", "utf-8")
|
|
40
41
|
template = await vite.transformIndexHtml(url, template)
|
|
41
|
-
render = (await vite.ssrLoadModule("/src/entry-server.
|
|
42
|
+
render = (await vite.ssrLoadModule("/src/entry-server.js")).render
|
|
42
43
|
} else {
|
|
43
44
|
template = await fs.readFile("./dist/client/index.html", "utf-8")
|
|
44
|
-
|
|
45
|
+
const serverEntry = "./dist/server/entry-server.js"
|
|
46
|
+
render = (await import(serverEntry)).render
|
|
45
47
|
}
|
|
46
|
-
const html = template.replace(`<!--ssr-outlet-->`,
|
|
48
|
+
const html = template.replace(`<!--ssr-outlet-->`, () => render())
|
|
47
49
|
res.status(200).set({ "Content-Type": "text/html" }).end(html)
|
|
48
50
|
} catch (e) {
|
|
49
|
-
vite?.ssrFixStacktrace(e)
|
|
50
|
-
console.
|
|
51
|
-
res.status(500).end(
|
|
51
|
+
if (e instanceof Error) vite?.ssrFixStacktrace(e)
|
|
52
|
+
console.error(e)
|
|
53
|
+
res.status(500).end()
|
|
52
54
|
}
|
|
53
55
|
})
|
|
54
56
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import viteLogo from "@/assets/vite.svg"
|
|
2
|
+
import hyperappLogo from "@/assets/hyperapp.svg"
|
|
3
|
+
|
|
4
|
+
const Logos = () => (
|
|
5
|
+
<>
|
|
6
|
+
<a href="https://vitejs.dev">
|
|
7
|
+
<img src={viteLogo} class="logo" alt="Vite logo" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://github.com/jorgebucaran/hyperapp">
|
|
10
|
+
<img src={hyperappLogo} class="logo" alt="Hyperapp logo" />
|
|
11
|
+
</a>
|
|
12
|
+
</>
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export default Logos
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "./style.css"
|
|
2
|
-
import
|
|
3
|
-
import viteLogo from "/vite.svg"
|
|
2
|
+
import Logos from "./logos"
|
|
4
3
|
import Counter from "./counter"
|
|
5
4
|
|
|
6
5
|
export const init = () => ({
|
|
@@ -12,17 +11,6 @@ const HandleClick = state => ({
|
|
|
12
11
|
counter: state.counter + 1,
|
|
13
12
|
})
|
|
14
13
|
|
|
15
|
-
const Logos = () => (
|
|
16
|
-
<>
|
|
17
|
-
<a href="https://vitejs.dev">
|
|
18
|
-
<img src={viteLogo} class="logo" alt="Vite logo" />
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://hyperapp.dev/">
|
|
21
|
-
<img src={hyperappLogo} class="logo vanilla" alt="Hyperapp logo" />
|
|
22
|
-
</a>
|
|
23
|
-
</>
|
|
24
|
-
)
|
|
25
|
-
|
|
26
14
|
export const view = state => (
|
|
27
15
|
<main id="app">
|
|
28
16
|
<h1>Vite (SSR) + Hyperapp</h1>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
import hyperapp from "vite-plugin-hyperapp"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
base: process.env.BASE || "/",
|
|
7
|
+
plugins: [hyperapp()],
|
|
8
|
+
resolve: {
|
|
9
|
+
alias: {
|
|
10
|
+
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>__PROJECTNAME__</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main id="app"></main>
|
|
11
|
+
<script type="module" src="/src/run.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "__PROJECTNAME__",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "vite build",
|
|
9
9
|
"preview": "vite preview"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"hyperapp": "^2.0.22"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"
|
|
16
|
-
"vite": "^
|
|
17
|
-
"vite-plugin-hyperapp": "^1.3.0"
|
|
15
|
+
"vite": "^8.3.4",
|
|
16
|
+
"vite-plugin-hyperapp": "^2.0.4"
|
|
18
17
|
}
|
|
19
18
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from "hyperapp"
|
|
2
|
+
import hyperappLogo from "@/assets/hyperapp.svg"
|
|
3
|
+
import viteLogo from "@/assets/vite.svg"
|
|
4
|
+
|
|
5
|
+
const Logos = () => [
|
|
6
|
+
h("a", { href: "https://vitejs.dev" }, [
|
|
7
|
+
h("img", { src: viteLogo, class: "logo", alt: "Vite logo" }),
|
|
8
|
+
]),
|
|
9
|
+
h("a", { href: "https://github.com/jorgebucaran/hyperapp" }, [
|
|
10
|
+
h("img", {
|
|
11
|
+
src: hyperappLogo,
|
|
12
|
+
class: "logo",
|
|
13
|
+
alt: "Hyperapp logo",
|
|
14
|
+
}),
|
|
15
|
+
]),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
export default Logos
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./style.css"
|
|
2
|
+
import { h, text } from "hyperapp"
|
|
3
|
+
import Counter from "./counter"
|
|
4
|
+
import Logos from "./logos"
|
|
5
|
+
|
|
6
|
+
export const init = () => ({
|
|
7
|
+
counter: 0,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const HandleClick = state => ({
|
|
11
|
+
...state,
|
|
12
|
+
counter: state.counter + 1,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const view = state =>
|
|
16
|
+
h("main", { id: "app" }, [
|
|
17
|
+
h("h1", {}, text("Vite + Hyperapp")),
|
|
18
|
+
...Logos(),
|
|
19
|
+
Counter({ clicks: state.counter, onclick: HandleClick }),
|
|
20
|
+
h(
|
|
21
|
+
"p",
|
|
22
|
+
{ class: "read-the-docs" },
|
|
23
|
+
text("Click on the Vite & Hyperapp logos to learn more"),
|
|
24
|
+
),
|
|
25
|
+
])
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
import hyperapp from "vite-plugin-hyperapp"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [hyperapp()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>__PROJECTNAME__</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<!--ssr-outlet-->
|
|
11
|
+
<script type="module" src="/src/entry-client.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "__PROJECTNAME__",
|
|
3
3
|
"private": true,
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "node server",
|
|
7
|
+
"dev": "node server.js",
|
|
8
8
|
"build:client": "vite build --outDir dist/client",
|
|
9
|
-
"build:server": "vite build --outDir dist/server --ssr src/entry-server.
|
|
9
|
+
"build:server": "vite build --outDir dist/server --ssr src/entry-server.js",
|
|
10
10
|
"build": "npm run build:client && npm run build:server",
|
|
11
|
-
"preview": "NODE_ENV=production node server"
|
|
11
|
+
"preview": "NODE_ENV=production node server.js"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"
|
|
15
|
-
"vite": "^4.5.14",
|
|
16
|
-
"vite-plugin-hyperapp": "^1.3.0"
|
|
14
|
+
"vite": "^8.3.4"
|
|
17
15
|
},
|
|
18
16
|
"dependencies": {
|
|
19
|
-
"hyperapp": "^2.0.22",
|
|
20
17
|
"compression": "^1.7.4",
|
|
21
18
|
"express": "^4.19.2",
|
|
22
|
-
"
|
|
19
|
+
"hyperapp": "^2.0.22",
|
|
20
|
+
"sirv": "^2.0.4",
|
|
21
|
+
"vite-plugin-hyperapp": "^2.0.4"
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
---------------------------------
|
|
3
|
+
Cribbed to large extent from template-ssr-solid/server.js
|
|
4
|
+
---------------------------------
|
|
5
|
+
*/
|
|
6
|
+
import fs from "node:fs/promises"
|
|
7
|
+
import express from "express"
|
|
8
|
+
|
|
9
|
+
const isProduction = process.env.NODE_ENV === "production"
|
|
10
|
+
const port = process.env.PORT || 5173
|
|
11
|
+
const base = process.env.BASE || "/"
|
|
12
|
+
|
|
13
|
+
async function createServer() {
|
|
14
|
+
const app = express()
|
|
15
|
+
|
|
16
|
+
let vite
|
|
17
|
+
if (!isProduction) {
|
|
18
|
+
const { createServer } = await import("vite")
|
|
19
|
+
vite = await createServer({
|
|
20
|
+
server: { middlewareMode: true },
|
|
21
|
+
appType: "custom",
|
|
22
|
+
})
|
|
23
|
+
app.use(vite.middlewares)
|
|
24
|
+
} else {
|
|
25
|
+
const compression = (await import("compression")).default
|
|
26
|
+
const sirv = (await import("sirv")).default
|
|
27
|
+
app.use(compression())
|
|
28
|
+
app.use(base, sirv("./dist/client", { extensions: [] }))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
app.use("*", async (req, res, next) => {
|
|
32
|
+
const url = req.originalUrl
|
|
33
|
+
if (!url.startsWith(base)) return next()
|
|
34
|
+
try {
|
|
35
|
+
let template
|
|
36
|
+
let render
|
|
37
|
+
if (!isProduction) {
|
|
38
|
+
if (!vite) throw new Error("Vite dev server is not initialized")
|
|
39
|
+
// Always read fresh template in development
|
|
40
|
+
template = await fs.readFile("./index.html", "utf-8")
|
|
41
|
+
template = await vite.transformIndexHtml(url, template)
|
|
42
|
+
render = (await vite.ssrLoadModule("/src/entry-server.js")).render
|
|
43
|
+
} else {
|
|
44
|
+
template = await fs.readFile("./dist/client/index.html", "utf-8")
|
|
45
|
+
const serverEntry = "./dist/server/entry-server.js"
|
|
46
|
+
render = (await import(serverEntry)).render
|
|
47
|
+
}
|
|
48
|
+
const html = template.replace(`<!--ssr-outlet-->`, () => render())
|
|
49
|
+
res.status(200).set({ "Content-Type": "text/html" }).end(html)
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e instanceof Error) vite?.ssrFixStacktrace(e)
|
|
52
|
+
console.error(e)
|
|
53
|
+
res.status(500).end()
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
app.listen(port, () => {
|
|
58
|
+
console.log(`Server started at http://localhost:${port}`)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
createServer()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from "hyperapp"
|
|
2
|
+
import hyperappLogo from "@/assets/hyperapp.svg"
|
|
3
|
+
import viteLogo from "@/assets/vite.svg"
|
|
4
|
+
|
|
5
|
+
const Logos = () => [
|
|
6
|
+
h("a", { href: "https://vitejs.dev" }, [
|
|
7
|
+
h("img", { src: viteLogo, class: "logo", alt: "Vite logo" }),
|
|
8
|
+
]),
|
|
9
|
+
h("a", { href: "https://github.com/jorgebucaran/hyperapp" }, [
|
|
10
|
+
h("img", {
|
|
11
|
+
src: hyperappLogo,
|
|
12
|
+
class: "logo",
|
|
13
|
+
alt: "Hyperapp logo",
|
|
14
|
+
}),
|
|
15
|
+
]),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
export default Logos
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./style.css"
|
|
2
|
+
import { h, text } from "hyperapp"
|
|
3
|
+
import Counter from "./counter"
|
|
4
|
+
import Logos from "./logos"
|
|
5
|
+
|
|
6
|
+
export const init = () => ({
|
|
7
|
+
counter: 0,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const HandleClick = state => ({
|
|
11
|
+
...state,
|
|
12
|
+
counter: state.counter + 1,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const view = state =>
|
|
16
|
+
h("main", { id: "app" }, [
|
|
17
|
+
h("h1", {}, text("Vite (SSR) + Hyperapp")),
|
|
18
|
+
...Logos(),
|
|
19
|
+
Counter({ clicks: state.counter, onclick: HandleClick }),
|
|
20
|
+
h(
|
|
21
|
+
"p",
|
|
22
|
+
{ class: "read-the-docs" },
|
|
23
|
+
text("Click on the Vite & Hyperapp logos to learn more"),
|
|
24
|
+
),
|
|
25
|
+
])
|