8 |
9 | ## Getting Started
10 |
11 | - `npm run dev` - Starts a dev server at http://localhost:5173/
12 |
13 | - `npm run build` - Builds for production, emitting to `dist/`
14 |
15 | - `npm run preview` - Starts a server at http://localhost:4173/ to test production build locally
16 |
--------------------------------------------------------------------------------
/templates/config/prerender/README.md:
--------------------------------------------------------------------------------
1 | # `create-preact`
2 |
3 |
4 |
5 |
6 |
7 |
Get started using Preact and Vite!
8 |
9 | ## Getting Started
10 |
11 | - `npm run dev` - Starts a dev server at http://localhost:5173/
12 |
13 | - `npm run build` - Builds for production, emitting to `dist/`. Prerenders app to static HTML
14 |
15 | - `npm run preview` - Starts a server at http://localhost:4173/ to test production build locally
16 |
--------------------------------------------------------------------------------
/templates/config/prerender-router/README.md:
--------------------------------------------------------------------------------
1 | # `create-preact`
2 |
3 |
4 |
5 |
6 |
7 |
Get started using Preact and Vite!
8 |
9 | ## Getting Started
10 |
11 | - `npm run dev` - Starts a dev server at http://localhost:5173/
12 |
13 | - `npm run build` - Builds for production, emitting to `dist/`. Prerenders all found routes in app to static HTML
14 |
15 | - `npm run preview` - Starts a server at http://localhost:4173/ to test production build locally
16 |
--------------------------------------------------------------------------------
/templates/base/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "module": "ESNext",
5 | "moduleResolution": "bundler",
6 | "noEmit": true,
7 | "allowJs": true,
8 | "checkJs": true,
9 |
10 | /* Preact Config */
11 | "jsx": "react-jsx",
12 | "jsxImportSource": "preact",
13 | "skipLibCheck": true,
14 | "paths": {
15 | "react": ["./node_modules/preact/compat/"],
16 | "react-dom": ["./node_modules/preact/compat/"],
17 | "react-dom/*": ["./node_modules/preact/compat/*"]
18 | }
19 | },
20 | "include": ["node_modules/vite/client.d.ts", "**/*"]
21 | }
22 |
--------------------------------------------------------------------------------
/templates/config/router/index.jsx:
--------------------------------------------------------------------------------
1 | import { render } from 'preact';
2 | import { LocationProvider, Router, Route } from 'preact-iso';
3 |
4 | import { Header } from './components/Header.jsx';
5 | import { Home } from './pages/Home/index.jsx';
6 | import { NotFound } from './pages/_404.jsx';
7 | import './style.css';
8 |
9 | export function App() {
10 | return (
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 | }
22 |
23 | render(, document.getElementById('app'));
24 |
--------------------------------------------------------------------------------
/templates/config/prerender-router/src/index.jsx:
--------------------------------------------------------------------------------
1 | import { LocationProvider, Router, Route, hydrate, prerender as ssr } from 'preact-iso';
2 |
3 | import { Header } from './components/Header.jsx';
4 | import { Home } from './pages/Home/index.jsx';
5 | import { NotFound } from './pages/_404.jsx';
6 | import './style.css';
7 |
8 | export function App() {
9 | return (
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | );
20 | }
21 |
22 | if (typeof window !== 'undefined') {
23 | hydrate(, document.getElementById('app'));
24 | }
25 |
26 | export async function prerender(data) {
27 | return await ssr();
28 | }
29 |
--------------------------------------------------------------------------------
/templates/config/router/pages/Home/style.css:
--------------------------------------------------------------------------------
1 | img {
2 | margin-bottom: 1.5rem;
3 | }
4 |
5 | img:hover {
6 | filter: drop-shadow(0 0 2em #673ab8aa);
7 | }
8 |
9 | .home section {
10 | margin-top: 5rem;
11 | display: grid;
12 | grid-template-columns: repeat(3, 1fr);
13 | column-gap: 1.5rem;
14 | }
15 |
16 | .resource {
17 | padding: 0.75rem 1.5rem;
18 | border-radius: 0.5rem;
19 | text-align: left;
20 | text-decoration: none;
21 | color: #222;
22 | background-color: #f1f1f1;
23 | border: 1px solid transparent;
24 | }
25 |
26 | .resource:hover {
27 | border: 1px solid #000;
28 | box-shadow: 0 25px 50px -12px #673ab888;
29 | }
30 |
31 | @media (max-width: 639px) {
32 | .home section {
33 | margin-top: 5rem;
34 | grid-template-columns: 1fr;
35 | row-gap: 1rem;
36 | }
37 | }
38 |
39 | @media (prefers-color-scheme: dark) {
40 | .resource {
41 | color: #ccc;
42 | background-color: #161616;
43 | }
44 | .resource:hover {
45 | border: 1px solid #bbb;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "create-preact",
3 | "version": "0.5.3",
4 | "description": "Create a Vite-powered Preact app in seconds",
5 | "type": "module",
6 | "bin": {
7 | "create-preact": "src/index.js"
8 | },
9 | "scripts": {
10 | "format": "prettier --write --ignore-path .gitignore ."
11 | },
12 | "authors": "The Preact Authors (https://preactjs.com)",
13 | "license": "MIT",
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/preactjs/create-preact.git"
17 | },
18 | "files": [
19 | "src",
20 | "templates",
21 | "LICENSE",
22 | "package.json",
23 | "README.md"
24 | ],
25 | "dependencies": {
26 | "@clack/prompts": "^0.9.0",
27 | "kolorist": "^1.8.0",
28 | "tinyexec": "^0.3.1"
29 | },
30 | "devDependencies": {
31 | "@types/node": "^20.2.3",
32 | "preact": "^10.15.0",
33 | "prettier": "^2.6.2",
34 | "prettier-config-rschristian": "^0.1.1",
35 | "typescript": "^5.0.0"
36 | },
37 | "prettier": "prettier-config-rschristian"
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 The Preact Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/templates/config/router/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color: #222;
7 | background-color: #ffffff;
8 |
9 | font-synthesis: none;
10 | text-rendering: optimizeLegibility;
11 | -webkit-font-smoothing: antialiased;
12 | -moz-osx-font-smoothing: grayscale;
13 | -webkit-text-size-adjust: 100%;
14 | }
15 |
16 | body {
17 | margin: 0;
18 | }
19 |
20 | #app {
21 | display: flex;
22 | flex-direction: column;
23 | min-height: 100vh;
24 | }
25 |
26 | header {
27 | display: flex;
28 | justify-content: flex-end;
29 | background-color: #673ab8;
30 | }
31 |
32 | header nav {
33 | display: flex;
34 | }
35 |
36 | header a {
37 | color: #fff;
38 | padding: 0.75rem;
39 | text-decoration: none;
40 | }
41 |
42 | header a.active {
43 | background-color: #0005;
44 | }
45 |
46 | header a:hover {
47 | background-color: #0008;
48 | }
49 |
50 | main {
51 | flex: auto;
52 | display: flex;
53 | align-items: center;
54 | max-width: 1280px;
55 | margin: 0 auto;
56 | text-align: center;
57 | }
58 |
59 | @media (max-width: 639px) {
60 | main {
61 | margin: 2rem;
62 | }
63 | }
64 |
65 | @media (prefers-color-scheme: dark) {
66 | :root {
67 | color: #ccc;
68 | background-color: #1a1a1a;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/templates/config/router/pages/Home/index.jsx:
--------------------------------------------------------------------------------
1 | import preactLogo from '../../assets/preact.svg';
2 | import './style.css';
3 |
4 | export function Home() {
5 | return (
6 |