-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
85 lines (82 loc) · 2.29 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
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
/// <reference types="vite/client" />
/* eslint-disable import/no-extraneous-dependencies */
import { preact } from '@preact/preset-vite';
import { resolve } from 'node:path';
import { vavite } from 'vavite';
import { defineConfig, type UserConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
const dirname = typeof __dirname === 'undefined' ? import.meta.dirname : __dirname;
const viteResolve: UserConfig['resolve'] = {
alias: [
{ find: /^~client(?=\/)/, replacement: resolve(dirname, 'src/client') },
{ find: /^~db(?=\/)/, replacement: resolve(dirname, 'src/db') },
{ find: /^~icons(?=\/)/, replacement: resolve(dirname, 'node_modules/bootstrap-icons/icons') },
{ find: /^~server(?=\/)/, replacement: resolve(dirname, 'src/server') },
{ find: /^~shared(?=\/)/, replacement: resolve(dirname, 'src/shared') },
{ find: /^~test(?=\/)/, replacement: resolve(dirname, 'test') },
],
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
};
// https://vitejs.dev/config/
export default defineConfig({
buildSteps: [
{
name: 'client',
config: {
build: {
manifest: true,
outDir: '.build/client',
},
resolve: viteResolve,
root: '.',
plugins: [],
},
},
{
name: 'server',
config: {
define: {
'process.env.DB_NAME': JSON.stringify(process.env.DB_NAME || 'books'),
'process.env.APP_VERSION': JSON.stringify(process.env.APP_VERSION || 'unknown'),
},
build: {
outDir: '.build/server',
ssr: 'src/server',
target: 'node22',
},
},
},
],
resolve: viteResolve,
server: {
host: '0.0.0.0',
port: 3000,
strictPort: true,
hmr: {
port: 6453,
},
},
plugins: [
preact(),
svgr({
svgrOptions: {
// TODO: pending https://github.com/gregberge/svgr/pull/927
// jsxRuntime: 'classic-preact',
svgProps: {
role: 'img',
},
},
// esbuildOptions: {
// jsxFactory: 'h',
// jsxFragment: 'Fragment',
// },
}),
vavite({
bundleSirv: false,
handlerEntry: 'src/server/handler.ts',
serverEntry: 'src/server/index.ts',
reloadOn: 'any-change',
serveClientAssetsInDev: true,
}),
],
});