Skip to content

Commit 905cb65

Browse files
committed
feat: preact templates
1 parent 62925eb commit 905cb65

18 files changed

+330
-1
lines changed

packages/create-app/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ const { prompt } = require('enquirer')
88

99
const cwd = process.cwd()
1010

11+
const TEMPLATES = [
12+
'vanilla',
13+
'vue',
14+
'vue-ts',
15+
'react',
16+
'react-ts',
17+
'preact',
18+
'preact-ts'
19+
]
20+
1121
const renameFiles = {
1222
_gitignore: '.gitignore'
1323
}
@@ -64,7 +74,7 @@ async function init() {
6474
type: 'select',
6575
name: 't',
6676
message: `Select a template:`,
67-
choices: ['vanilla', 'vue', 'vue-ts', 'react', 'react-ts']
77+
choices: TEMPLATES
6878
})
6979
template = t
7080
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Vite App</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "vite-preact-ts-starter",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"dev": "vite",
6+
"build": "tsc && vite build"
7+
},
8+
"dependencies": {
9+
"preact": "^10.5.9"
10+
},
11+
"devDependencies": {
12+
"@prefresh/vite": "^2.0.0",
13+
"typescript": "^4.1.3",
14+
"vite": "^2.0.0-beta.10"
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { h, Fragment } from 'preact'
2+
import { Logo } from './logo'
3+
4+
export function App() {
5+
return (
6+
<>
7+
<Logo />
8+
<p>Hello Vite + Preact!</p>
9+
<p>
10+
<a
11+
class="link"
12+
href="https://preactjs.com/"
13+
target="_blank"
14+
rel="noopener noreferrer"
15+
>
16+
Learn Preact
17+
</a>
18+
</p>
19+
</>
20+
)
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
html, body {
2+
height: 100%;
3+
width: 100%;
4+
padding: 0;
5+
margin: 0;
6+
background: #FAFAFA;
7+
font-family: 'Helvetica Neue', arial, sans-serif;
8+
font-weight: 400;
9+
color: #444;
10+
-webkit-font-smoothing: antialiased;
11+
-moz-osx-font-smoothing: grayscale;
12+
}
13+
14+
* {
15+
box-sizing: border-box;
16+
}
17+
18+
#app {
19+
height: 100%;
20+
text-align: center;
21+
background-color: #673ab8;
22+
color: #fff;
23+
font-size: 1.5em;
24+
padding-top: 100px;
25+
}
26+
27+
.link {
28+
color: #fff;
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { h } from 'preact'
2+
3+
export const Logo = () => (
4+
<svg
5+
class="logo"
6+
height="180px"
7+
viewBox="-256 -256 1800 512"
8+
title="Preact"
9+
style="
10+
display: inline-block;
11+
margin: -0.25em 0px 0px;
12+
vertical-align: middle;
13+
"
14+
>
15+
<path
16+
d="M0,-256 221.7025033688164,-128 221.7025033688164,128 0,256 -221.7025033688164,128 -221.7025033688164,-128z"
17+
fill="white"
18+
></path>
19+
<ellipse
20+
cx="0"
21+
cy="0"
22+
rx="75px"
23+
ry="196px"
24+
stroke-width="16px"
25+
stroke-dasharray="365.2604060943886 81.7395939056114"
26+
stroke-dashoffset="1131.9689975248618"
27+
fill="none"
28+
stroke="#673ab8"
29+
transform="rotate(52)"
30+
></ellipse>
31+
<ellipse
32+
cx="0"
33+
cy="0"
34+
rx="75px"
35+
ry="196px"
36+
stroke-width="16px"
37+
stroke-dasharray="403.1225208830963 43.87747911690373"
38+
stroke-dashoffset="-963.0079812482553"
39+
fill="none"
40+
stroke="#673ab8"
41+
transform="rotate(-52)"
42+
></ellipse>
43+
<circle cx="0" cy="0" r="34" fill="#673ab8"></circle>
44+
<path
45+
fill="white"
46+
d="M289.85 25.25L289.85 125L272 125L272-122.63L335.88-122.63Q379.45-122.63 401.59-103.55Q423.73-84.48 423.73-49.13Q423.73-32.85 417.69-19.20Q411.65-5.55 400.27 4.34Q388.90 14.22 372.63 19.74Q356.35 25.25 335.88 25.25L289.85 25.25M289.85 10.90L335.88 10.90Q352.33 10.90 365.27 6.35Q378.23 1.80 387.24-6.25Q396.25-14.30 401.06-25.24Q405.88-36.18 405.88-49.13Q405.88-77.65 388.29-93.05Q370.70-108.45 335.88-108.45L289.85-108.45L289.85 10.90ZM497.58 13.00L497.58 125L479.73 125L479.73-122.63L542.90-122.63Q585.78-122.63 606.95-106.09Q628.13-89.55 628.13-57.53Q628.13-43.35 623.23-31.63Q618.33-19.90 609.14-11.06Q599.95-2.23 587 3.46Q574.05 9.15 557.78 10.90Q561.98 13.52 565.30 17.90L650.53 125L634.95 125Q632.15 125 630.14 123.95Q628.13 122.90 626.20 120.45L546.93 20.00Q543.95 16.15 540.54 14.57Q537.13 13.00 529.95 13.00L497.58 13.00M497.58-0.30L540.63-0.30Q557.08-0.30 570.11-4.24Q583.15-8.18 592.16-15.53Q601.18-22.88 605.90-33.20Q610.63-43.53 610.63-56.48Q610.63-82.90 593.30-95.68Q575.98-108.45 542.90-108.45L497.58-108.45L497.58-0.30ZM843.73-122.63L843.73-107.75L713.35-107.75L713.35-7.65L821.85-7.65L821.85 6.87L713.35 6.87L713.35 110.13L843.73 110.13L843.73 125L695.33 125L695.33-122.63L843.73-122.63ZM1088.55 125L1074.73 125Q1072.28 125 1070.70 123.69Q1069.13 122.38 1068.25 120.28L1039.03 48.35L917.40 48.35L888.35 120.28Q887.65 122.20 885.90 123.60Q884.15 125 881.70 125L868.05 125L969.38-122.63L987.23-122.63L1088.55 125M922.83 35.05L1033.78 35.05L983.20-90.08Q981.98-93.05 980.75-96.81Q979.53-100.58 978.30-104.78Q977.08-100.58 975.85-96.81Q974.63-93.05 973.40-89.90L922.83 35.05ZM1302.40 83.35Q1304.15 83.35 1305.38 84.57L1312.38 92.10Q1304.67 100.33 1295.58 106.89Q1286.47 113.45 1275.71 118.09Q1264.95 122.72 1252.09 125.26Q1239.22 127.80 1223.83 127.80Q1198.10 127.80 1176.66 118.79Q1155.22 109.78 1139.91 93.24Q1124.60 76.70 1116.03 53.25Q1107.45 29.80 1107.45 1.10Q1107.45-27.08 1116.29-50.35Q1125.13-73.63 1141.14-90.34Q1157.15-107.05 1179.46-116.24Q1201.78-125.43 1228.72-125.43Q1242.20-125.43 1253.40-123.41Q1264.60-121.40 1274.31-117.64Q1284.03-113.88 1292.60-108.28Q1301.17-102.68 1309.40-95.33L1303.97-87.45Q1302.58-85.35 1299.60-85.35Q1298.03-85.35 1295.58-87.19Q1293.13-89.03 1289.36-91.74Q1285.60-94.45 1280.26-97.69Q1274.92-100.93 1267.58-103.64Q1260.22-106.35 1250.60-108.19Q1240.97-110.03 1228.72-110.03Q1206.15-110.03 1187.25-102.24Q1168.35-94.45 1154.70-80.01Q1141.05-65.58 1133.44-45.01Q1125.83-24.45 1125.83 1.10Q1125.83 27.35 1133.35 48.00Q1140.88 68.65 1154.17 82.91Q1167.47 97.17 1185.59 104.79Q1203.70 112.40 1224.88 112.40Q1238.17 112.40 1248.59 110.65Q1259 108.90 1267.75 105.40Q1276.50 101.90 1284.03 96.82Q1291.55 91.75 1298.90 84.92Q1299.78 84.22 1300.56 83.79Q1301.35 83.35 1302.40 83.35ZM1530.42-122.63L1530.42-107.40L1443.45-107.40L1443.45 125L1425.60 125L1425.60-107.40L1338.10-107.40L1338.10-122.63L1530.42-122.63Z"
47+
></path>
48+
</svg>
49+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { render, h } from 'preact'
2+
import { App } from './app'
3+
import './index.css'
4+
5+
render(<App />, document.getElementById('app')!)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
{
3+
"compilerOptions": {
4+
"target": "ESNext",
5+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
6+
"types": [],
7+
"allowJs": false,
8+
"skipLibCheck": false,
9+
"esModuleInterop": false,
10+
"allowSyntheticDefaultImports": true,
11+
"strict": true,
12+
"forceConsistentCasingInFileNames": true,
13+
"module": "ESNext",
14+
"moduleResolution": "Node",
15+
"resolveJsonModule": true,
16+
"isolatedModules": true,
17+
"noEmit": true,
18+
"jsx": "react",
19+
"jsxFactory": "h",
20+
"jsxFragmentFactory": "Fragment"
21+
},
22+
"include": ["src"]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import preactRefresh from '@prefresh/vite'
2+
import { defineConfig } from 'vite'
3+
4+
export default defineConfig({
5+
esbuild: {
6+
jsxFactory: 'h',
7+
jsxFragment: 'Fragment'
8+
},
9+
plugins: [preactRefresh()]
10+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Vite App</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.jsx"></script>
11+
</body>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "vite-preact-starter",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"dev": "vite",
6+
"build": "vite build"
7+
},
8+
"dependencies": {
9+
"preact": "^10.5.9"
10+
},
11+
"devDependencies": {
12+
"@prefresh/vite": "^2.0.0",
13+
"vite": "^2.0.0-beta.11"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Logo } from './logo'
2+
3+
export function App(props) {
4+
return (
5+
<>
6+
<Logo />
7+
<p>Hello Vite + Preact!</p>
8+
<p>
9+
<a
10+
class="link"
11+
href="https://preactjs.com/"
12+
target="_blank"
13+
rel="noopener noreferrer"
14+
>
15+
Learn Preact
16+
</a>
17+
</p>
18+
</>
19+
)
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
html, body {
2+
height: 100%;
3+
width: 100%;
4+
padding: 0;
5+
margin: 0;
6+
background: #FAFAFA;
7+
font-family: 'Helvetica Neue', arial, sans-serif;
8+
font-weight: 400;
9+
color: #444;
10+
-webkit-font-smoothing: antialiased;
11+
-moz-osx-font-smoothing: grayscale;
12+
}
13+
14+
* {
15+
box-sizing: border-box;
16+
}
17+
18+
#app {
19+
height: 100%;
20+
text-align: center;
21+
background-color: #673ab8;
22+
color: #fff;
23+
font-size: 1.5em;
24+
padding-top: 100px;
25+
}
26+
27+
.link {
28+
color: #fff;
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
export const Logo = () => (
2+
<svg
3+
class="logo"
4+
height="180px"
5+
viewBox="-256 -256 1800 512"
6+
title="Preact"
7+
style="
8+
display: inline-block;
9+
margin: -0.25em 0px 0px;
10+
vertical-align: middle;
11+
"
12+
>
13+
<path
14+
d="M0,-256 221.7025033688164,-128 221.7025033688164,128 0,256 -221.7025033688164,128 -221.7025033688164,-128z"
15+
fill="white"
16+
></path>
17+
<ellipse
18+
cx="0"
19+
cy="0"
20+
rx="75px"
21+
ry="196px"
22+
stroke-width="16px"
23+
stroke-dasharray="365.2604060943886 81.7395939056114"
24+
stroke-dashoffset="1131.9689975248618"
25+
fill="none"
26+
stroke="#673ab8"
27+
transform="rotate(52)"
28+
></ellipse>
29+
<ellipse
30+
cx="0"
31+
cy="0"
32+
rx="75px"
33+
ry="196px"
34+
stroke-width="16px"
35+
stroke-dasharray="403.1225208830963 43.87747911690373"
36+
stroke-dashoffset="-963.0079812482553"
37+
fill="none"
38+
stroke="#673ab8"
39+
transform="rotate(-52)"
40+
></ellipse>
41+
<circle cx="0" cy="0" r="34" fill="#673ab8"></circle>
42+
<path
43+
fill="white"
44+
d="M289.85 25.25L289.85 125L272 125L272-122.63L335.88-122.63Q379.45-122.63 401.59-103.55Q423.73-84.48 423.73-49.13Q423.73-32.85 417.69-19.20Q411.65-5.55 400.27 4.34Q388.90 14.22 372.63 19.74Q356.35 25.25 335.88 25.25L289.85 25.25M289.85 10.90L335.88 10.90Q352.33 10.90 365.27 6.35Q378.23 1.80 387.24-6.25Q396.25-14.30 401.06-25.24Q405.88-36.18 405.88-49.13Q405.88-77.65 388.29-93.05Q370.70-108.45 335.88-108.45L289.85-108.45L289.85 10.90ZM497.58 13.00L497.58 125L479.73 125L479.73-122.63L542.90-122.63Q585.78-122.63 606.95-106.09Q628.13-89.55 628.13-57.53Q628.13-43.35 623.23-31.63Q618.33-19.90 609.14-11.06Q599.95-2.23 587 3.46Q574.05 9.15 557.78 10.90Q561.98 13.52 565.30 17.90L650.53 125L634.95 125Q632.15 125 630.14 123.95Q628.13 122.90 626.20 120.45L546.93 20.00Q543.95 16.15 540.54 14.57Q537.13 13.00 529.95 13.00L497.58 13.00M497.58-0.30L540.63-0.30Q557.08-0.30 570.11-4.24Q583.15-8.18 592.16-15.53Q601.18-22.88 605.90-33.20Q610.63-43.53 610.63-56.48Q610.63-82.90 593.30-95.68Q575.98-108.45 542.90-108.45L497.58-108.45L497.58-0.30ZM843.73-122.63L843.73-107.75L713.35-107.75L713.35-7.65L821.85-7.65L821.85 6.87L713.35 6.87L713.35 110.13L843.73 110.13L843.73 125L695.33 125L695.33-122.63L843.73-122.63ZM1088.55 125L1074.73 125Q1072.28 125 1070.70 123.69Q1069.13 122.38 1068.25 120.28L1039.03 48.35L917.40 48.35L888.35 120.28Q887.65 122.20 885.90 123.60Q884.15 125 881.70 125L868.05 125L969.38-122.63L987.23-122.63L1088.55 125M922.83 35.05L1033.78 35.05L983.20-90.08Q981.98-93.05 980.75-96.81Q979.53-100.58 978.30-104.78Q977.08-100.58 975.85-96.81Q974.63-93.05 973.40-89.90L922.83 35.05ZM1302.40 83.35Q1304.15 83.35 1305.38 84.57L1312.38 92.10Q1304.67 100.33 1295.58 106.89Q1286.47 113.45 1275.71 118.09Q1264.95 122.72 1252.09 125.26Q1239.22 127.80 1223.83 127.80Q1198.10 127.80 1176.66 118.79Q1155.22 109.78 1139.91 93.24Q1124.60 76.70 1116.03 53.25Q1107.45 29.80 1107.45 1.10Q1107.45-27.08 1116.29-50.35Q1125.13-73.63 1141.14-90.34Q1157.15-107.05 1179.46-116.24Q1201.78-125.43 1228.72-125.43Q1242.20-125.43 1253.40-123.41Q1264.60-121.40 1274.31-117.64Q1284.03-113.88 1292.60-108.28Q1301.17-102.68 1309.40-95.33L1303.97-87.45Q1302.58-85.35 1299.60-85.35Q1298.03-85.35 1295.58-87.19Q1293.13-89.03 1289.36-91.74Q1285.60-94.45 1280.26-97.69Q1274.92-100.93 1267.58-103.64Q1260.22-106.35 1250.60-108.19Q1240.97-110.03 1228.72-110.03Q1206.15-110.03 1187.25-102.24Q1168.35-94.45 1154.70-80.01Q1141.05-65.58 1133.44-45.01Q1125.83-24.45 1125.83 1.10Q1125.83 27.35 1133.35 48.00Q1140.88 68.65 1154.17 82.91Q1167.47 97.17 1185.59 104.79Q1203.70 112.40 1224.88 112.40Q1238.17 112.40 1248.59 110.65Q1259 108.90 1267.75 105.40Q1276.50 101.90 1284.03 96.82Q1291.55 91.75 1298.90 84.92Q1299.78 84.22 1300.56 83.79Q1301.35 83.35 1302.40 83.35ZM1530.42-122.63L1530.42-107.40L1443.45-107.40L1443.45 125L1425.60 125L1425.60-107.40L1338.10-107.40L1338.10-122.63L1530.42-122.63Z"
45+
></path>
46+
</svg>
47+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { render } from 'preact'
2+
import { App } from './app'
3+
import './index.css'
4+
5+
render(<App />, document.getElementById('app'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @ts-check
2+
import preactRefresh from '@prefresh/vite'
3+
4+
/**
5+
* @type { import('vite').UserConfig }
6+
*/
7+
const config = {
8+
esbuild: {
9+
jsxFactory: 'h',
10+
jsxFragment: 'Fragment',
11+
jsxInject: `import { h, Fragment } from 'preact'`
12+
},
13+
plugins: [preactRefresh()]
14+
}
15+
16+
export default config

0 commit comments

Comments
 (0)