forked from bancorprotocol/carbon-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
79 lines (71 loc) · 2.14 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
import { defineConfig, loadEnv, PluginOption } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import pluginRewriteAll from 'vite-plugin-rewrite-all';
// https://vitejs.dev/config/
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(), '');
const plugins: PluginOption[] = [
react(),
viteTsconfigPaths(),
svgrPlugin(),
pluginRewriteAll(),
];
// Put the Sentry vite plugin after all other plugins
if (env.SENTRY_ORG && env.SENTRY_PROJECT && env.SENTRY_AUTH_TOKEN) {
plugins.push(
sentryVitePlugin({
org: env.SENTRY_ORG,
project: env.SENTRY_PROJECT,
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
authToken: env.SENTRY_AUTH_TOKEN,
sourcemaps: {
// Specify the directory containing build artifacts
assets: './build/**',
},
// Use the following option if you're on an SDK version lower than 7.47.0:
// include: "./dist",
// Optionally uncomment the line below to override automatic release name detection
// release: env.RELEASE,
})
);
}
return {
build: {
outDir: 'build',
sourcemap: !!(
env.SENTRY_ORG &&
env.SENTRY_PROJECT &&
env.SENTRY_AUTH_TOKEN
),
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
},
resolve: {
alias: {
process: 'process/browser',
buffer: 'buffer',
crypto: 'crypto-browserify',
stream: 'stream-browserify',
assert: 'assert',
http: 'stream-http',
https: 'https-browserify',
os: 'os-browserify',
url: 'url',
util: 'util',
},
},
server: {
port: 3000,
},
plugins,
};
});