-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.client.ts
More file actions
87 lines (85 loc) · 2.42 KB
/
vite.config.client.ts
File metadata and controls
87 lines (85 loc) · 2.42 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// vite.client.config.ts
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig, loadEnv } from 'vite';
import checker from 'vite-plugin-checker';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), 'VITE_');
console.log(`Building client for mode: ${mode}`);
return {
plugins: [
tsconfigPaths({ projects: ['./tsconfig.client.json'] }), // Ensure paths are resolved before other plugins
react(),
{
name: 'worker-loader',
transform(code, id) {
if (id.endsWith('.worker.ts')) {
console.debug(`Transforming worker: ${id}`);
return {
code: `export default function WorkerWrapper() {
return new Worker(new URL('${id}', import.meta.url), { type: 'module' })
}`,
map: null,
};
}
},
},
checker({ typescript: true }), // Type checking
],
build: {
outDir: 'dist/client',
rollupOptions: {
input: './src/main.tsx', // Changed from src/client/main.tsx
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]',
format: 'es',
},
external: ['fsevents', 'formidable'],
},
sourcemap: true,
minify: 'terser',
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
secure: false,
},
},
},
worker: {
format: 'es',
rollupOptions: {
output: {
entryFileNames: 'workers/[name].[hash].js',
chunkFileNames: 'workers/[name].[hash].js',
},
},
},
optimizeDeps: {
include: ['react', 'react-dom', 'axios'],
exclude: [],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@client': path.resolve(__dirname, './src/client'),
'@shared': path.resolve(__dirname, './src/shared'),
'@server': path.resolve(__dirname, './src/server'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
},
root: process.cwd(),
css: {
modules: {
localsConvention: 'camelCase',
generateScopedName: '[name]__[local]__[hash:base64:5]',
},
},
};
});