-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
33 lines (29 loc) · 1.05 KB
/
vite.config.ts
File metadata and controls
33 lines (29 loc) · 1.05 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
import react from '@vitejs/plugin-react'
import { config } from 'dotenv'
import { defineConfig } from 'vite'
import topLevelAwait from 'vite-plugin-top-level-await'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const TopLevelAwaitPlugin = topLevelAwait as any
config()
const parsedPort = Number.parseInt(process.env.PORT ?? '')
const port = Number.isNaN(parsedPort) ? 3000 : parsedPort
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
plugins: [react(), {
...TopLevelAwaitPlugin({
// The export name of top-level await promise for each chunk module
promiseExportName: '__tla',
// The function to generate import names of top-level await promise in each chunk module
// eslint-disable-next-line @typescript-eslint/no-explicit-any
promiseImportName: (i: any) => `__tla_${i}`,
}),
apply: 'serve',
}],
build: {
sourcemap: true,
rollupOptions: { output: { entryFileNames: 'assets/index-main-[hash].js' }, external: ['events'] },
outDir: 'build',
},
server: { port },
})