-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
56 lines (51 loc) · 1.33 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
/// <reference types="vitest" />
import { VitePWA } from 'vite-plugin-pwa'
import react from '@vitejs/plugin-react'
import pwaManifestConfig from './manifest.config.js'
import tsconfigPaths from 'vite-tsconfig-paths'
import { loadEnv, splitVendorChunkPlugin } from 'vite'
import { defineConfig } from 'vitest/dist/config.js'
import viteRollbar from 'vite-plugin-rollbar'
// References:
// https://vitejs.dev/config/
// https://vite-pwa-org.netlify.app/assets-generator/#example-using-minimal-preset
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const plugins = [
tsconfigPaths(),
react(),
VitePWA(pwaManifestConfig),
splitVendorChunkPlugin(),
]
if (env.ROLLBAR_ACCESS_TOKEN) {
plugins.push(
viteRollbar({
accessToken: env.ROLLBAR_ACCESS_TOKEN,
baseUrl: `https://${env.HOSTNAME}`,
version: '1.0',
ignoreUploadErrors: true,
silent: false,
}),
)
}
return {
build: {
sourcemap: true,
},
plugins,
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['src/test/setup.ts'],
},
server: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: false,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
}
})