Skip to content

Commit 9e2badc

Browse files
authored
Make Vite plugin compatible with Vite < 7 (TypeScript-wise) (#542)
Closes #533 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a new Vite-legacy playground environment with React, TypeScript, and modern development tooling. * Integrated environment variable management with validation support. * **Documentation** * Added setup and configuration guides for the new playground environment. * **Chores** * Updated workspace and project configurations. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 434f0d6 commit 9e2badc

22 files changed

Lines changed: 416 additions & 23 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PORT=3000
2+
VITE_MY_VAR=test
3+
VITE_MY_NUMBER=123
4+
VITE_MY_BOOLEAN=true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PORT=3000
2+
VITE_MY_VAR=test
3+
VITE_MY_NUMBER=123
4+
VITE_MY_BOOLEAN=true
Lines changed: 24 additions & 0 deletions
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?
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## React Compiler
11+
12+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13+
14+
## Linting and Formatting
15+
16+
This project uses [Biome](https://biomejs.dev/) for linting and formatting, enforced via the monorepo root configuration.
17+
18+
### Configuration
19+
20+
The configuration is located in the root `biome.jsonc` file. It includes:
21+
22+
- **Formatter**: Indentation with tabs, double quotes.
23+
- **Linter**: Recommended rules enabled, with some customizations (e.g., `noConsole` is off for playgrounds).
24+
- **Organize Imports**: Enabled.
25+
26+
### Commands
27+
28+
To run linting and formatting, use the following commands from the root or within the workspace:
29+
30+
```bash
31+
# Check for lint errors and formatting differences
32+
pnpm check
33+
34+
# Fix auto-fixable lint errors and format code
35+
pnpm fix
36+
```
37+
Lines changed: 13 additions & 0 deletions
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-legacy</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "vite-legacy-playground",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"@arkenv/vite-plugin": "workspace:*",
13+
"arkenv": "workspace:*",
14+
"arktype": "catalog:",
15+
"react": "19.2.1",
16+
"react-dom": "19.2.1"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^24.10.1",
20+
"@types/react": "^19.2.5",
21+
"@types/react-dom": "^19.2.3",
22+
"@vitejs/plugin-react": "^5.1.1",
23+
"globals": "^16.5.0",
24+
"typescript": "~5.9.3",
25+
"vite": "7.2.7",
26+
"vite-tsconfig-paths": "catalog:"
27+
}
28+
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useState } from "react";
2+
import viteLogo from "/vite.svg";
3+
import reactLogo from "./assets/react.svg";
4+
import "./app.css";
5+
6+
function App() {
7+
const [count, setCount] = useState(0);
8+
9+
return (
10+
<>
11+
<div>
12+
<a href="https://vite.dev" target="_blank" rel="noopener noreferrer">
13+
<img src={viteLogo} className="logo" alt="Vite logo" />
14+
</a>
15+
<a href="https://react.dev" target="_blank" rel="noopener noreferrer">
16+
<img src={reactLogo} className="logo react" alt="React logo" />
17+
</a>
18+
</div>
19+
<h1>Vite + React</h1>
20+
<div className="card">
21+
<button type="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 className="read-the-docs">
29+
Click on the Vite and React logos to learn more
30+
</p>
31+
</>
32+
);
33+
}
34+
35+
export default App;
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)