-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
48 lines (45 loc) · 1.29 KB
/
vite.config.js
File metadata and controls
48 lines (45 loc) · 1.29 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
import devServer from '@hono/vite-dev-server';
import { defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
// Load env files
const env = loadEnv(mode, process.cwd(), '');
// Dev config
if (mode === 'development') {
return {
base: '/api',
plugins: [
devServer({
entry: './src/server.ts',
}),
],
}
}
// Build config
return {
build: {
minify: false,
lib: {
entry: {
server: './src/server.ts',
},
formats: ['es']
},
rollupOptions: {
external: (id) => {
// Keep relative imports as part of the bundle
if (id.startsWith('.') || id.startsWith('/')) {
return false;
}
// Externalize all node modules and absolute imports
return true;
},
output: {
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames: '[name].js'
}
},
outDir: 'dist'
},
}
});