Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
67 lines (61 loc) · 1.79 KB
/
Copy pathvite.config.ts
File metadata and controls
67 lines (61 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { defineConfig, type UserConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { vitePrerenderPlugin } from "vite-prerender-plugin"
import path from "node:path"
import { fileURLToPath } from 'node:url'
// Configuração para suportar __dirname em ambientes ESM (Node.js moderno)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
let build: UserConfig['build'] = {}
let esbuild: UserConfig['esbuild'] = {}
let define: UserConfig['define'] = {}
// Configurações específicas para o modo de desenvolvimento
if (mode === 'development') {
build = {
minify: false,
sourcemap: true,
rollupOptions: {
output: {
manualChunks: undefined,
},
},
}
esbuild = {
keepNames: true,
minifyIdentifiers: false,
}
define = {
'process.env.NODE_ENV': '"development"',
'__DEV__': 'true',
}
}
return {
plugins: [
react(),
// Garante que o script de pré-renderização seja encontrado corretamente
vitePrerenderPlugin({
renderTarget: '#root',
prerenderScript: path.resolve(__dirname, 'src/prerender.tsx'),
}),
],
build,
esbuild,
define,
resolve: {
alias: {
// CORREÇÃO: Usa o caminho absoluto para evitar erros de importação com '@'
'@': path.resolve(__dirname, './src'),
}
},
server: {
// Tudo que o front pedir para /api/... é repassado ao backend (porta 3001).
proxy: { '/api': 'http://localhost:3001' },
},
optimizeDeps: {
// Inclui lucide-react para garantir que os ícones sejam pré-processados corretamente
include: ['lucide-react'],
},
}
})