-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
66 lines (63 loc) · 2.83 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
import path, { resolve } from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig, loadEnv } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import replace from '@rollup/plugin-replace';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const apiKey = env.VITE_FIREBASE_API_KEY || process.env.VITE_FIREBASE_API_KEY;
const authDomain = env.VITE_FIREBASE_AUTH_DOMAIN || process.env.VITE_FIREBASE_AUTH_DOMAIN;
const projectId = env.VITE_FIREBASE_PROJECT_ID || process.env.VITE_FIREBASE_PROJECT_ID;
const storageBucket = env.VITE_FIREBASE_STORAGE_BUCKET || process.env.VITE_FIREBASE_STORAGE_BUCKET;
const messagingSenderId = env.VITE_FIREBASE_MESSAGING_SENDER_ID || process.env.VITE_FIREBASE_MESSAGING_SENDER_ID;
const appId = env.VITE_FIREBASE_APP_ID || process.env.VITE_FIREBASE_APP_ID;
const sentryAuthToken = env.SENTRY_AUTH_TOKEN || process.env.SENTRY_AUTH_TOKEN;
return {
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
'firebase-vendor': ['firebase/app', 'firebase/firestore'],
}
}
},
chunkSizeWarningLimit: 1000
},
plugins: [
react(),
replace({
'process.env.VITE_FIREBASE_API_KEY': JSON.stringify(apiKey),
'process.env.VITE_FIREBASE_AUTH_DOMAIN': JSON.stringify(authDomain),
'process.env.VITE_FIREBASE_PROJECT_ID': JSON.stringify(projectId),
'process.env.VITE_FIREBASE_STORAGE_BUCKET': JSON.stringify(storageBucket),
'process.env.VITE_FIREBASE_MESSAGING_SENDER_ID': JSON.stringify(messagingSenderId),
'process.env.VITE_FIREBASE_APP_ID': JSON.stringify(appId),
preventAssignment: true
}),
// Put the Sentry vite plugin after all other plugins
sentryVitePlugin({
authToken: sentryAuthToken,
org: 'bumgeun-song',
project: 'daily-writing-friends',
})
],
define: {
'process.env.VITE_FIREBASE_API_KEY': JSON.stringify(apiKey),
'process.env.VITE_FIREBASE_AUTH_DOMAIN': JSON.stringify(authDomain),
'process.env.VITE_FIREBASE_PROJECT_ID': JSON.stringify(projectId),
'process.env.VITE_FIREBASE_STORAGE_BUCKET': JSON.stringify(storageBucket),
'process.env.VITE_FIREBASE_MESSAGING_SENDER_ID': JSON.stringify(messagingSenderId),
'process.env.VITE_FIREBASE_APP_ID': JSON.stringify(appId),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'#minpath': path.resolve(__dirname, 'node_modules/vfile/lib/minpath.browser.js'),
'#minproc': path.resolve(__dirname, 'node_modules/vfile/lib/minproc.browser.js'),
'#minurl': path.resolve(__dirname, 'node_modules/vfile/lib/minurl.browser.js'),
},
},
};
});