-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.server.ts
More file actions
70 lines (68 loc) · 1.97 KB
/
vite.config.server.ts
File metadata and controls
70 lines (68 loc) · 1.97 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
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.info(`Building server for mode: ${mode}`);
return {
plugins: [
tsconfigPaths({ projects: ['./tsconfig.server.json'] }),
{
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 }),
],
build: {
outDir: 'dist/server',
rollupOptions: {
input: './src/entry-server.tsx', // Ensure this points to the correct SSR entry
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]',
format: 'es',
},
external: [
'express',
'mongoose',
'cors',
'fsevents',
'formidable',
'dotenv',
// Add other server-side dependencies as needed
],
},
sourcemap: true,
minify: 'terser',
ssr: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@shared': path.resolve(__dirname, './src/shared'),
'@client': path.resolve(__dirname, './src/client'),
'@server': path.resolve(__dirname, './src/server'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
},
optimizeDeps: {
include: ['react', 'react-dom', 'axios'],
exclude: [],
},
server: {
port: 3000, // Fixed port for server
},
};
});