-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
74 lines (71 loc) · 1.89 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
import honeybadgerRollupPlugin from '@honeybadger-io/rollup-plugin'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import svgr from 'vite-plugin-svgr'
import wasm from 'vite-plugin-wasm'
import { ManifestOptions, VitePWA } from 'vite-plugin-pwa'
import browserslist from 'browserslist'
import { resolveToEsbuildTarget } from 'esbuild-plugin-browserslist'
import topLevelAwait from 'vite-plugin-top-level-await' // Need it because of vite-plugin-pwa
import manifest from './src/manifest.json'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const isProd = mode === 'production';
const env = loadEnv(mode, process.cwd());
const hbPluginOptions = {
apiKey: env.VITE_HONEYBADGER_API_KEY,
assetsUrl: 'https://lisudoku.xyz',
environment: mode,
deploy: true,
}
return {
base: '/',
plugins: [
react(),
viteTsconfigPaths(),
svgr({
include: '**/*.svg?react',
}),
wasm(),
topLevelAwait(),
VitePWA({
registerType: 'autoUpdate',
strategies: 'injectManifest',
srcDir: 'src',
filename: 'sw.ts',
devOptions: {
enabled: true,
type: 'module',
},
manifest: manifest as Partial<ManifestOptions>,
}),
],
worker: {
plugins: () => [
wasm(),
topLevelAwait(),
],
},
build: {
target: resolveToEsbuildTarget(browserslist(null, { env: mode, throwOnMissing: true })),
outDir: 'build',
sourcemap: true,
rollupOptions: {
// Upload sourcemaps on deployment
plugins: isProd ? [ honeybadgerRollupPlugin(hbPluginOptions) ] : [],
}
},
server: {
open: true,
},
resolve: {
alias: {
src: '/src',
},
},
define: {
global: {},
},
}
})