Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit d63a908

Browse files
Initial commit with Vite/Preact
1 parent 1b28dcf commit d63a908

14 files changed

+212
-1
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

docs/assets/index.79b09e21.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/index.b09fabce.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Preact</title>
8+
<script type="module" crossorigin src="/assets/index.79b09e21.js"></script>
9+
<link rel="stylesheet" href="/assets/index.b09fabce.css">
10+
</head>
11+
<body>
12+
<div id="app"></div>
13+
14+
</body>
15+
</html>

images/logo.svg

+1
Loading

index.html

+13-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
Hello, world
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Preact</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vite-preact-starter",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"preact": "^10.11.0"
13+
},
14+
"devDependencies": {
15+
"@preact/preset-vite": "^2.4.0",
16+
"vite": "^3.1.3"
17+
}
18+
}

src/app.css

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#app {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
}
12+
.logo:hover {
13+
filter: drop-shadow(0 0 2em #646cffaa);
14+
}
15+
.logo.preact:hover {
16+
filter: drop-shadow(0 0 2em #673ab8aa);
17+
}
18+
19+
.card {
20+
padding: 2em;
21+
}
22+
23+
.read-the-docs {
24+
color: #888;
25+
}

src/app.jsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useState } from 'preact/hooks'
2+
import './app.css'
3+
4+
export function App() {
5+
const [count, setCount] = useState(0)
6+
7+
return (
8+
<>
9+
<div>
10+
<a href="https://preactjs.com" target="_blank">
11+
<img src="/images/logo.svg" class="logo preact" alt="Preact logo" />
12+
</a>
13+
</div>
14+
<h1>Vite + Preact</h1>
15+
<div class="card">
16+
<button onClick={() => setCount((count) => count + 1)}>
17+
count is {count}
18+
</button>
19+
<p>
20+
Edit <code>src/app.jsx</code> and save to test HMR
21+
</p>
22+
</div>
23+
<p class="read-the-docs">
24+
Click on the Vite and Preact logos to learn more
25+
</p>
26+
</>
27+
)
28+
}

src/assets/cloudy-favicon.png

2.78 KB
Loading

src/index.css

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
:root {
2+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3+
font-size: 16px;
4+
line-height: 24px;
5+
font-weight: 400;
6+
7+
color-scheme: light dark;
8+
color: rgba(255, 255, 255, 0.87);
9+
background-color: #242424;
10+
11+
font-synthesis: none;
12+
text-rendering: optimizeLegibility;
13+
-webkit-font-smoothing: antialiased;
14+
-moz-osx-font-smoothing: grayscale;
15+
-webkit-text-size-adjust: 100%;
16+
}
17+
18+
a {
19+
font-weight: 500;
20+
color: #646cff;
21+
text-decoration: inherit;
22+
}
23+
a:hover {
24+
color: #535bf2;
25+
}
26+
27+
body {
28+
margin: 0;
29+
display: flex;
30+
place-items: center;
31+
min-width: 320px;
32+
min-height: 100vh;
33+
}
34+
35+
h1 {
36+
font-size: 3.2em;
37+
line-height: 1.1;
38+
}
39+
40+
button {
41+
border-radius: 8px;
42+
border: 1px solid transparent;
43+
padding: 0.6em 1.2em;
44+
font-size: 1em;
45+
font-weight: 500;
46+
font-family: inherit;
47+
background-color: #1a1a1a;
48+
cursor: pointer;
49+
transition: border-color 0.25s;
50+
}
51+
button:hover {
52+
border-color: #646cff;
53+
}
54+
button:focus,
55+
button:focus-visible {
56+
outline: 4px auto -webkit-focus-ring-color;
57+
}
58+
59+
@media (prefers-color-scheme: light) {
60+
:root {
61+
color: #213547;
62+
background-color: #ffffff;
63+
}
64+
a:hover {
65+
color: #747bff;
66+
}
67+
button {
68+
background-color: #f9f9f9;
69+
}
70+
}

src/main.jsx

+5
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'))

vite.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'vite'
2+
import preact from '@preact/preset-vite'
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [preact()],
7+
build: {
8+
outDir: 'docs'
9+
}
10+
})

0 commit comments

Comments
 (0)