01
Premiers pas
Créer un projet
Générez des projets à partir de templates.
vite
# npm create vite@latest my-app -- --template vue
# npm create vite@latest my-app -- --template react-tsConfig
Configuration Vite avec plugins.
vite
// vite.config.ts
import { defineConfig } from "vite";
export default defineConfig({
plugins: [vue()],
server: { port: 3000 },
});Dev/Build
Trois commandes principales.
vite
# vite # dev server
# vite build # production build
# vite preview # preview build02
Fonctionnalités
Plugins
Les plugins étendent les fonctionnalités de Vite.
vite
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
});Variables d'environnement
Le préfixe VITE_ expose les variables d'environnement au client.
vite
import.meta.env.VITE_API_URL
// .env
VITE_API_URL=https://api.example.comProxy
Proxifiez les requêtes API pendant le développement.
vite
server: {
proxy: {
"/api": "http://localhost:8080",
},
}Was this helpful?