-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.js
62 lines (61 loc) · 2.53 KB
/
vite.config.js
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
import react from '@vitejs/plugin-react';
import { defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [react()],
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
},
jsxInject: `import React from 'react'`,
resolve: {
alias: [
{ find: '@assets', replacement: '/src/assets' },
{ find: '@components', replacement: '/src/components' },
{ find: '@pages', replacement: '/src/pages' },
{ find: '@styles', replacement: '/src/styles' },
{ find: '@contexts', replacement: '/src/contexts' },
{ find: '@hooks', replacement: '/src/hooks' },
{ find: '@utils', replacement: '/src/utils' },
],
},
define: {
// Some libraries use the global object, even though it doesn't exist in the browser.
// Alternatively, we could add `<script>window.global = window;</script>` to index.html.
// https://github.com/vitejs/vite/discussions/5912
global: 'window',
'process.env': process.env,
// Mainnet
'import.meta.env.MAINNET_NETWORK': JSON.stringify(env.MAINNET_NETWORK),
'import.meta.env.MAINNET_NETWORK_URL': JSON.stringify(
env.MAINNET_NETWORK_URL
),
'import.meta.env.MAINNET_MPG_NAME': JSON.stringify(env.MAINNET_MPG_NAME),
'import.meta.env.MAINNET_MPG_KEY': JSON.stringify(env.MAINNET_MPG_KEY),
'import.meta.env.MAINNET_PRODUCT_NAME': JSON.stringify(
env.MAINNET_PRODUCT_NAME
),
// Devnet
'import.meta.env.DEVNET_NETWORK': JSON.stringify(env.DEVNET_NETWORK),
'import.meta.env.DEVNET_NETWORK_URL': JSON.stringify(
env.DEVNET_NETWORK_URL
),
'import.meta.env.DEVNET_MPG_KEY': JSON.stringify(env.DEVNET_MPG_KEY),
// Testnet
'import.meta.env.TESTNET_NETWORK': JSON.stringify(env.TESTNET_NETWORK),
'import.meta.env.TESTNET_NETWORK_URL': JSON.stringify(
env.TESTNET_NETWORK_URL
),
'import.meta.env.TESTNET_MPG_KEY': JSON.stringify(env.TESTNET_MPG_KEY),
// API
'import.meta.env.API_URL': JSON.stringify(env.API_URL),
'import.meta.env.URL_SOLANA': JSON.stringify(env.URL_SOLANA),
// TOKEN
'import.meta.env.USDC_TOKEN_MINT': JSON.stringify(env.USDC_TOKEN_MINT),
'import.meta.env.TOKEN_PROGRAM_ID': JSON.stringify(env.TOKEN_PROGRAM_ID),
},
};
});