-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
124 lines (119 loc) · 3.63 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import path from 'path';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { configDefaults } from 'vitest/config';
import { lingui } from '@lingui/vite-plugin';
import tailwindcss from 'tailwindcss';
import simpleHtmlPlugin from 'vite-plugin-simple-html';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const RPC_PROVIDER_MAINNET = process.env.VITE_RPC_PROVIDER_MAINNET || '';
const RPC_PROVIDER_SEPOLIA = process.env.VITE_RPC_PROVIDER_SEPOLIA || '';
const RPC_PROVIDER_TENDERLY = process.env.VITE_RPC_PROVIDER_TENDERLY || '';
const RPC_PROVIDER_BASE = process.env.VITE_RPC_PROVIDER_BASE || '';
const RPC_PROVIDER_TENDERLY_BASE = process.env.VITE_RPC_PROVIDER_TENDERLY_BASE || '';
const CONTENT_SECURITY_POLICY = `
default-src 'self';
script-src 'self'
https://cdn.markfi.xyz
https://static.cloudflareinsights.com
https://challenges.cloudflare.com;
style-src 'self' 'unsafe-inline';
img-src 'self' data: blob: https://explorer-api.walletconnect.com;
font-src 'self';
connect-src 'self'
${RPC_PROVIDER_MAINNET}
${RPC_PROVIDER_TENDERLY}
${RPC_PROVIDER_SEPOLIA}
${RPC_PROVIDER_BASE}
${RPC_PROVIDER_TENDERLY_BASE}
https://virtual.mainnet.rpc.tenderly.co
https://virtual.base.rpc.tenderly.co
https://rpc.sepolia.org
https://mainnet.base.org
https://vote.makerdao.com
https://query-subgraph-testnet.sky.money
https://query-subgraph-staging.sky.money
https://query-subgraph.sky.money
https://api.thegraph.com
https://staging-api.sky.money
https://api.sky.money
https://api.ipify.org
https://info-sky.blockanalitica.com
https://sky-tenderly.blockanalitica.com
https://api.cow.fi/
wss://relay.walletconnect.com
wss://relay.walletconnect.org
https://pulse.walletconnect.org
wss://www.walletlink.org
https://explorer-api.walletconnect.com/
https://enhanced-provider.rainbow.me
https://a.markfi.xyz/
cloudflareinsights.com;
frame-src 'self'
https://verify.walletconnect.com
https://verify.walletconnect.org
`;
// Need to remove whitespaces otherwise the app won't build due to unsupported characters
const parsedCSP = CONTENT_SECURITY_POLICY.replace(/\n/g, '');
return defineConfig({
server: {
// vite default is 5173
port: 3000
},
preview: {
port: 3000
},
root: 'src',
envDir: '../',
build: {
outDir: '../dist',
emptyOutDir: true
},
test: {
exclude: [...configDefaults.exclude],
globals: true,
environment: 'happy-dom'
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
optimizeDeps: {
// Optimize safe-apps-provider dependency to get rid of the Safe connector issue
// and be able to connect Safe apps
include: ['wagmi > @safe-global/safe-apps-provider']
},
plugins: [
simpleHtmlPlugin({
minify: true,
inject: {
tags: [
{
tag: 'meta',
attrs: {
'http-equiv': 'Content-Security-Policy',
content: parsedCSP
}
}
]
}
}),
nodePolyfills({
include: ['buffer']
}),
react({
plugins: [['@lingui/swc-plugin', {}]]
}),
lingui()
],
css: {
postcss: {
plugins: [tailwindcss()]
}
}
});
};