Repository navigation
Expand file tree
/
Copy pathvite.config.mjs
More file actions
77 lines (72 loc) · 2.07 KB
/
Copy pathvite.config.mjs
File metadata and controls
77 lines (72 loc) · 2.07 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
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
import devServer, { defaultOptions } from '@hono/vite-dev-server';
import 'dotenv/config';
import { resolve } from 'path';
import { readdirSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const files = readdirSync('resources').filter((file) => file.endsWith('.html'));
const input = {};
for (const filename of files) {
input[filename.replace('.html', '')] = resolve(__dirname, `resources/${filename}`);
}
const port = Number.parseInt(process.env.PORT ?? '', 10) || 5555;
const nonBackendPath = /^(?!\/(?:api(?:\/|\?|$)|health(?:\/|\?|$)|ready(?:\/|\?|$))).*/;
function applicationRuntime() {
let stopRuntime;
return {
name: 'nara-application-runtime',
async configureServer(server) {
const runtime = await server.ssrLoadModule('../src/app/server.ts');
stopRuntime = runtime.initializeApplicationRuntime().stop;
server.httpServer?.once('close', () => {
stopRuntime?.();
stopRuntime = undefined;
});
},
};
}
export default defineConfig({
plugins: [
applicationRuntime(),
devServer({
entry: '../src/app/server.ts',
export: 'app',
injectClientScript: false,
// Hono owns only backend/reserved paths in development. Vue browser
// routes, assets, and Vite HMR remain native Vite requests.
exclude: [nonBackendPath, ...defaultOptions.exclude],
}),
tailwindcss(),
vue(),
],
root: 'resources',
publicDir: '../public',
server: {
host: '0.0.0.0',
port,
strictPort: true,
},
build: {
outDir: '../build/client',
emptyOutDir: true,
minify: 'oxc',
cssCodeSplit: true,
sourcemap: false,
target: 'es2022',
rollupOptions: {
input,
output: {
codeSplitting: {
groups: [
{ name: 'vendor-vue', test: /node_modules[\\/]vue/ },
],
},
},
},
},
});