fix: rebuild propre — 1 seul bundle, plugin clean-assets avant chaque build

This commit is contained in:
Gwadaking
2026-04-08 03:08:02 -04:00
parent 9f73639f25
commit 90bee1bfe9
11 changed files with 864 additions and 9 deletions

View File

@@ -1,11 +1,21 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { rmSync } from 'fs';
import path from 'path';
// Plugin qui nettoie uniquement public/assets/ avant chaque build
const cleanAssetsPlugin = () => ({
name: 'clean-assets',
buildStart() {
const dir = path.resolve(__dirname, '../backend/public/assets');
try { rmSync(dir, { recursive: true, force: true }); } catch {}
},
});
export default defineConfig({
plugins: [react()],
plugins: [react(), cleanAssetsPlugin()],
server: {
proxy: {
// En dev local, proxy /api → Symfony (port 8000)
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
@@ -14,6 +24,6 @@ export default defineConfig({
},
build: {
outDir: '../backend/public',
emptyOutDir: false, // ne pas supprimer index.php, .htaccess Symfony, etc.
emptyOutDir: false, // ne pas supprimer index.php
},
});