forked from djkcyl/D.I.G.E.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
94 lines (92 loc) · 3 KB
/
vite.config.js
File metadata and controls
94 lines (92 loc) · 3 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { readFileSync } from 'fs'
import { sentryVitePlugin } from '@sentry/vite-plugin'
import { VitePWA } from 'vite-plugin-pwa'
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN
const sentryOrg = process.env.SENTRY_ORG
const sentryProject = process.env.SENTRY_PROJECT
const sentryEnabled = Boolean(sentryAuthToken && sentryOrg && sentryProject)
export default defineConfig({
plugins: [
react(),
tailwindcss(),
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
manifestFilename: 'manifest.json',
includeAssets: ['favicon.png', 'icon-512.png', 'robots.txt'],
manifest: {
id: '/',
name: 'D.I.G.E. - Dijiang Integrated Generator Efficiency',
short_name: 'D.I.G.E.',
description: 'Thermal Pool power generation optimizer for Arknights: Endfield.',
start_url: '/',
scope: '/',
display: 'standalone',
display_override: ['standalone', 'minimal-ui'],
background_color: '#1a1a2e',
theme_color: '#1a1a2e',
orientation: 'any',
lang: 'zh-CN',
dir: 'ltr',
categories: ['games', 'utilities'],
icons: [
{
src: '/favicon.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any maskable',
},
{
src: '/icon-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
workbox: {
navigateFallback: '/index.html',
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,json}'],
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
},
devOptions: {
enabled: false,
},
}),
sentryEnabled
? sentryVitePlugin({
org: sentryOrg,
project: sentryProject,
authToken: sentryAuthToken,
release: { name: pkg.version },
sourcemaps: {
filesToDeleteAfterUpload: ['./dist/**/*.map'],
},
})
: null,
].filter(Boolean),
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('i18n') && (id.includes('locales') || id.endsWith('.json'))) return 'i18n';
if (id.includes('node_modules')) {
if ((id.includes('node_modules/react/') || id.includes('node_modules/react-dom/')) && !id.includes('react-chartjs') && !id.includes('@sentry')) return 'core';
if (id.includes('chart.js') || id.includes('react-chartjs')) return 'vendor';
if (id.includes('@iconify/react')) return 'vendor';
if (id.includes('@sentry/react')) return 'vendor';
if (id.includes('qrcode.react')) return 'vendor';
}
},
},
},
},
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
})