-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
60 lines (57 loc) · 1.94 KB
/
vite.config.ts
File metadata and controls
60 lines (57 loc) · 1.94 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
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react';
import { execSync } from 'child_process';
import { defineConfig, loadEnv } from 'vite';
import svgr from 'vite-plugin-svgr';
import { configDefaults } from 'vitest/config';
process.env.VITE_VERCEL_ENV = process.env.VERCEL_ENV || 'development';
const EXPLORER_REV = execSync('git rev-parse HEAD').toString().trim().toString();
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const sentryAuthToken = env.SENTRY_AUTH_TOKEN;
const IS_PROD = env.VITE_BUILD_ENV === 'production';
return {
plugins: [
react(),
svgr(),
sentryVitePlugin({
org: 'iota-foundation-eu',
project: 'iota-explorer',
authToken: sentryAuthToken,
sourcemaps: {
assets: './build/**',
},
disable: !IS_PROD || !sentryAuthToken,
silent: !env.CI,
release: {
name: EXPLORER_REV,
},
}),
],
test: {
// Omit end-to-end tests:
exclude: [...configDefaults.exclude, 'tests/**'],
css: true,
globals: true,
environment: 'happy-dom',
},
build: {
// Set the output directory to match what CRA uses:
outDir: 'build',
sourcemap: true,
},
resolve: {
alias: {
'~': new URL('./src', import.meta.url).pathname,
},
},
define: {
EXPLORER_REV: JSON.stringify(EXPLORER_REV),
'process.env.APPS_BACKEND': JSON.stringify(process.env.APPS_BACKEND ?? ''),
},
};
});