-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
89 lines (82 loc) · 2.88 KB
/
vite.config.ts
File metadata and controls
89 lines (82 loc) · 2.88 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
78
79
80
81
82
83
84
85
86
87
88
89
import { cloudflare } from '@cloudflare/vite-plugin'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import htmlPlugin from 'vite-plugin-html-config'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import getHtmlConfig from './html.config'
// import { analyzer } from 'vite-bundle-analyzer'
// https://vitejs.dev/config/
export default defineConfig(configEnv => {
const isDev = process.env.NODE_ENV === 'development' // local development
const isStaging = configEnv.mode === 'staging' // testnet
const isProduction = configEnv.mode === 'production' // mainnet
return {
// Frontend env
define: {
...(isStaging && {
APP_SALT: JSON.stringify('0x65a4dadb78fe3704825f49a55b251478c1cb1b682139f9c24d2828ac0410f200'),
APP_SESSION_SIGNER_ADDRESS: JSON.stringify('0xD9030071966102689a8bb6b71A8C2Fc56D1d26a5'),
APP_PUSH_FEEDBACK_PROJECT_ID: JSON.stringify('oc9bd4ntqh'),
}),
...(isProduction && {
APP_SALT: JSON.stringify('0x65a4dadb78fe3704825f49a55b251478c1cb1b682139f9c24d2828ac0410f200'),
APP_SESSION_SIGNER_ADDRESS: JSON.stringify('0xD9030071966102689a8bb6b71A8C2Fc56D1d26a5'),
APP_PUSH_FEEDBACK_PROJECT_ID: JSON.stringify('zzx8w12kkb'),
}),
// Must put below the values in staging and production to override them
...(isDev && {
APP_SALT: JSON.stringify('0xa581872589a5bce5483964bef2a258f2cbf64f66e19db1727f828c96dcf9db00'),
APP_SESSION_SIGNER_ADDRESS: JSON.stringify('0x70997970C51812dc3A010C7d01b50e0d17dc79C8'),
APP_PUSH_FEEDBACK_PROJECT_ID: JSON.stringify('oc9bd4ntqh'),
}),
},
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: tag => tag === 'feedback-button',
},
},
}),
nodePolyfills(),
AutoImport({
dts: 'src/auto-import.d.ts',
imports: ['vue', 'vue-router', 'pinia', '@vueuse/core', 'vitest'],
eslintrc: {
enabled: true,
},
}),
Components({
dts: 'src/components.d.ts',
}),
htmlPlugin(getHtmlConfig(isProduction, isStaging)),
cloudflare({
configPath: isProduction ? 'wrangler.production.jsonc' : 'wrangler.staging.jsonc',
}),
// analyzer(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@samanager/sdk': fileURLToPath(new URL('./packages/sdk/src/index.ts', import.meta.url)),
},
},
build: {
rollupOptions: {
output: {
manualChunks: (id: string) => {
// only create manual chunks for client build to prevent from empty chunks
if (process.env.SSR) return undefined
if (id.includes('sendop')) return 'sendop'
if (id.includes('ethers')) return 'ethers'
if (id.includes('radix-vue')) return 'radix-vue'
if (id.includes('@vueuse/core')) return '@vueuse/core'
},
},
},
},
}
})