Skip to content

Commit 277e844

Browse files
AbdelrahmanDwedarArnaudBarrebluwy
authored
feat(create-vite): add solidjs templates (#12218) (#12241)
Co-authored-by: Arnaud Barré <[email protected]> Co-authored-by: bluwy <[email protected]>
1 parent 8315f9e commit 277e844

28 files changed

+521
-1
lines changed

docs/guide/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The supported template presets are:
3636
| [preact](https://vite.new/preact) | [preact-ts](https://vite.new/preact-ts) |
3737
| [lit](https://vite.new/lit) | [lit-ts](https://vite.new/lit-ts) |
3838
| [svelte](https://vite.new/svelte) | [svelte-ts](https://vite.new/svelte-ts) |
39+
| [solid](https://vite.new/solid) | [solid-ts](https://vite.new/solid-ts) |
3940

4041
## Scaffolding Your First Vite Project
4142

@@ -79,7 +80,7 @@ yarn create vite my-vue-app --template vue
7980
pnpm create vite my-vue-app --template vue
8081
```
8182

82-
See [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) for more details on each supported template: `vanilla`, `vanilla-ts`, `vue`, `vue-ts`, `react`, `react-ts`, `react-swc`, `react-swc-ts`, `preact`, `preact-ts`, `lit`, `lit-ts`, `svelte`, `svelte-ts`.
83+
See [create-vite](https://github.com/vitejs/vite/tree/main/packages/create-vite) for more details on each supported template: `vanilla`, `vanilla-ts`, `vue`, `vue-ts`, `react`, `react-ts`, `react-swc`, `react-swc-ts`, `preact`, `preact-ts`, `lit`, `lit-ts`, `svelte`, `svelte-ts`, `solid`, `solid-ts`.
8384

8485
## Community Templates
8586

packages/create-vite/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Currently supported template presets include:
5757
- `lit-ts`
5858
- `svelte`
5959
- `svelte-ts`
60+
- `solid`
61+
- `solid-ts`
6062

6163
You can use `.` for the project name to scaffold in the current directory.
6264

packages/create-vite/src/index.ts

+17
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ const FRAMEWORKS: Framework[] = [
169169
},
170170
],
171171
},
172+
{
173+
name: 'solid',
174+
display: 'Solid',
175+
color: blue,
176+
variants: [
177+
{
178+
name: 'solid-ts',
179+
display: 'TypeScript',
180+
color: blue,
181+
},
182+
{
183+
name: 'solid',
184+
display: 'JavaScript',
185+
color: yellow,
186+
},
187+
],
188+
},
172189
{
173190
name: 'others',
174191
display: 'Others',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Usage
2+
3+
```bash
4+
$ npm install # or pnpm install or yarn install
5+
```
6+
7+
### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)
8+
9+
## Available Scripts
10+
11+
In the project directory, you can run:
12+
13+
### `npm run dev`
14+
15+
Runs the app in the development mode.<br>
16+
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.
17+
18+
### `npm run build`
19+
20+
Builds the app for production to the `dist` folder.<br>
21+
It correctly bundles Solid in production mode and optimizes the build for the best performance.
22+
23+
The build is minified and the filenames include the hashes.<br>
24+
Your app is ready to be deployed!
25+
26+
## Deployment
27+
28+
Learn more about deploying your application with the [documentations](https://vitejs.dev/guide/static-deploy.html)
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?
Original file line numberDiff line numberDiff line change
@@ -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="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + Solid + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/index.tsx"></script>
12+
</body>
13+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "vite-solid-typescript-starter",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"solid-js": "^1.7.7"
13+
},
14+
"devDependencies": {
15+
"typescript": "^5.0.2",
16+
"vite": "^4.3.9",
17+
"vite-plugin-solid": "^2.7.0"
18+
}
19+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#root {
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+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #646cffaa);
16+
}
17+
.logo.solid:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
.card {
22+
padding: 2em;
23+
}
24+
25+
.read-the-docs {
26+
color: #888;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createSignal } from 'solid-js'
2+
import solidLogo from './assets/solid.svg'
3+
import viteLogo from '/vite.svg'
4+
import './App.css'
5+
6+
function App() {
7+
const [count, setCount] = createSignal(0)
8+
9+
return (
10+
<>
11+
<div>
12+
<a href="https://vitejs.dev" target="_blank">
13+
<img src={viteLogo} class="logo" alt="Vite logo" />
14+
</a>
15+
<a href="https://solidjs.com" target="_blank">
16+
<img src={solidLogo} class="logo solid" alt="Solid logo" />
17+
</a>
18+
</div>
19+
<h1>Vite + Solid</h1>
20+
<div class="card">
21+
<button onClick={() => setCount((count) => count + 1)}>
22+
count is {count()}
23+
</button>
24+
<p>
25+
Edit <code>src/App.tsx</code> and save to test HMR
26+
</p>
27+
</div>
28+
<p class="read-the-docs">
29+
Click on the Vite and Solid logos to learn more
30+
</p>
31+
</>
32+
)
33+
}
34+
35+
export default App
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
-webkit-text-size-adjust: 100%;
15+
}
16+
17+
a {
18+
font-weight: 500;
19+
color: #646cff;
20+
text-decoration: inherit;
21+
}
22+
a:hover {
23+
color: #535bf2;
24+
}
25+
26+
body {
27+
margin: 0;
28+
display: flex;
29+
place-items: center;
30+
min-width: 320px;
31+
min-height: 100vh;
32+
}
33+
34+
h1 {
35+
font-size: 3.2em;
36+
line-height: 1.1;
37+
}
38+
39+
button {
40+
border-radius: 8px;
41+
border: 1px solid transparent;
42+
padding: 0.6em 1.2em;
43+
font-size: 1em;
44+
font-weight: 500;
45+
font-family: inherit;
46+
background-color: #1a1a1a;
47+
cursor: pointer;
48+
transition: border-color 0.25s;
49+
}
50+
button:hover {
51+
border-color: #646cff;
52+
}
53+
button:focus,
54+
button:focus-visible {
55+
outline: 4px auto -webkit-focus-ring-color;
56+
}
57+
58+
@media (prefers-color-scheme: light) {
59+
:root {
60+
color: #213547;
61+
background-color: #ffffff;
62+
}
63+
a:hover {
64+
color: #747bff;
65+
}
66+
button {
67+
background-color: #f9f9f9;
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* @refresh reload */
2+
import { render } from 'solid-js/web'
3+
4+
import './index.css'
5+
import App from './App'
6+
7+
const root = document.getElementById('root')
8+
9+
render(() => <App />, root!)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"noEmit": true,
15+
"jsx": "preserve",
16+
"jsxImportSource": "solid-js",
17+
18+
/* Linting */
19+
"strict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"noFallthroughCasesInSwitch": true
23+
},
24+
"include": ["src"],
25+
"references": [{ "path": "./tsconfig.node.json" }]
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true
8+
},
9+
"include": ["vite.config.ts"]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from 'vite'
2+
import solid from 'vite-plugin-solid'
3+
4+
export default defineConfig({
5+
plugins: [solid()],
6+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Usage
2+
3+
```bash
4+
$ npm install # or pnpm install or yarn install
5+
```
6+
7+
### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)
8+
9+
## Available Scripts
10+
11+
In the project directory, you can run:
12+
13+
### `npm run dev`
14+
15+
Runs the app in the development mode.<br>
16+
Open [http://localhost:5173](http://localhost:5173) to view it in the browser.
17+
18+
### `npm run build`
19+
20+
Builds the app for production to the `dist` folder.<br>
21+
It correctly bundles Solid in production mode and optimizes the build for the best performance.
22+
23+
The build is minified and the filenames include the hashes.<br>
24+
Your app is ready to be deployed!
25+
26+
## Deployment
27+
28+
Learn more about deploying your application with the [documentations](https://vitejs.dev/guide/static-deploy.html)
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?

0 commit comments

Comments
 (0)