-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathvite.config.ts
102 lines (94 loc) · 2.61 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import react from '@vitejs/plugin-react-swc'
import { resolve } from 'node:path'
import { defineConfig, loadEnv } from 'vite'
import { createHtmlPlugin } from 'vite-plugin-html'
import svgr from 'vite-plugin-svgr'
import topLevelAwait from 'vite-plugin-top-level-await'
import wasm from 'vite-plugin-wasm'
import { version } from './package.json'
const icons: Record<string, string> = {
development: '/favicon-local.svg',
production: '/favicon-prod.svg',
staging: '/favicon-staging.svg',
}
const titles: Record<string, string> = {
development: 'Lago - Local',
production: 'Lago',
staging: 'Lago - Cloud',
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const port = env.PORT ? parseInt(env.PORT) : 8080
return {
plugins: [
react({
plugins: [['@swc/plugin-styled-components', { displayName: true }]],
}),
wasm(),
topLevelAwait(),
svgr({
include: '**/*.svg',
svgrOptions: {
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
svgoConfig: {
plugins: [
{
name: 'prefixIds',
params: {
prefixIds: false,
prefixClassNames: false,
},
},
],
},
},
}),
createHtmlPlugin({
inject: {
data: {
title: titles[env.APP_ENV] || titles.production,
favicon: icons[env.APP_ENV] || icons.production,
},
},
}),
],
define: {
APP_ENV: JSON.stringify(env.APP_ENV),
API_URL: JSON.stringify(env.API_URL),
DOMAIN: JSON.stringify(env.LAGO_DOMAIN),
APP_VERSION: JSON.stringify(version),
LAGO_OAUTH_PROXY_URL: JSON.stringify(env.LAGO_OAUTH_PROXY_URL),
LAGO_DISABLE_SIGNUP: JSON.stringify(env.LAGO_DISABLE_SIGNUP),
NANGO_PUBLIC_KEY: JSON.stringify(env.NANGO_PUBLIC_KEY),
SENTRY_DSN: JSON.stringify(env.SENTRY_DSN),
},
resolve: {
alias: {
'~': resolve(__dirname, 'src'),
lodash: 'lodash-es',
'@mui/styled-engine': resolve(__dirname, 'node_modules/@mui/styled-engine-sc'),
},
},
server: {
port,
host: true,
strictPort: true,
allowedHosts: ['app.lago.dev'],
},
preview: {
port,
},
build: {
outDir: 'dist',
sourcemap: true,
target: 'esnext',
rollupOptions: {
output: {
chunkFileNames: '[name].[hash].js',
entryFileNames: '[name].[hash].js',
sourcemapFileNames: '[name].[hash].js.map',
},
},
},
}
})