-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
53 lines (50 loc) · 1.33 KB
/
vite.config.ts
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
import path from 'node:path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
const isSSRBuild = process.env.BUILD_MODE === 'ssr';
export default defineConfig({
base: '/',
build: {
emptyOutDir: !isSSRBuild,
manifest: !isSSRBuild,
outDir: path.resolve(__dirname, 'dist/client'),
rollupOptions: {
input: isSSRBuild
? {
server: path.resolve(__dirname, 'src/client/entry-server.tsx'),
}
: {
client: path.resolve(__dirname, 'src/client/entry-client.tsx'),
main: path.resolve(__dirname, 'src/client/index.html'),
},
},
ssr: isSSRBuild ? path.resolve(__dirname, 'src/client/entry-server.tsx') : undefined,
ssrManifest: isSSRBuild,
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
plugins: [react()],
publicDir: 'public',
resolve: {
alias: {
'@client': path.resolve(__dirname, 'src/client'),
'@server': path.resolve(__dirname, 'src/server'),
'@shared': path.resolve(__dirname, 'src/shared'),
},
},
root: path.resolve(__dirname, 'src/client'),
server: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
});