-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
77 lines (74 loc) · 1.81 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
/// <reference types="vitest" />
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import environment from 'vite-plugin-environment';
import dotenv from 'dotenv';
import path from 'path';
export default defineConfig(({ mode }) => {
console.log('mode = ', mode);
if (mode === 'sandbox' || mode === 'production') {
dotenv.config({ path: `.env.${mode}` });
} else {
dotenv.config();
}
const domain = mode === 'sandbox' ? 'sandbox.icramp.xyz' : 'app.icramp.xyz';
return {
root: 'src',
build: {
outDir: '../dist',
emptyOutDir: true,
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
server: {
proxy: {
'/api': {
target: 'http://127.0.0.1:4943',
changeOrigin: true,
},
},
},
plugins: [
react(),
environment('all', { prefix: 'CANISTER_' }),
environment('all', { prefix: 'DFX_' }),
environment('all', { prefix: 'CONTRACT_' }),
environment('all', { prefix: 'FRONTEND_' }),
{
name: 'copy-assets',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: '.well-known/ic-domains',
source: domain,
});
this.emitFile({
type: 'asset',
fileName: '.ic-assets.json',
source: '[{"match": ".well-known", "ignore": false}]',
});
},
},
],
test: {
environment: 'jsdom',
setupFiles: 'setupTests.ts',
cache: { dir: '../node_modules/.vitest' },
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "${path.resolve(
__dirname,
'src/index.css',
)}";`,
},
},
},
};
});