-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathvite.config.js
More file actions
109 lines (96 loc) · 3.14 KB
/
Copy pathvite.config.js
File metadata and controls
109 lines (96 loc) · 3.14 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import UnoCSS from 'unocss/vite'
import { resolve } from 'path'
import { existsSync } from 'fs'
import wasm from 'vite-plugin-wasm'
const isDev = process.env.NODE_ENV === 'development'
const isTauriDebug = process.env.TAURI_DEBUG === 'true'
const isCommunity = process.env.QC_COMMUNITY === '1'
export default defineConfig({
root: 'src',
clearScreen: false,
server: {
port: 1421,
strictPort: true,
fs: {
allow: [
resolve(__dirname, '.'),
resolve(__dirname, 'node_modules'),
resolve(__dirname, 'src'),
],
},
},
envPrefix: ['VITE_', 'TAURI_'],
resolve: {
preserveSymlinks: true,
alias: {
'@': resolve(__dirname, 'src'),
'@shared': resolve(__dirname, 'src/shared'),
'@windows': resolve(__dirname, 'src/windows'),
'uno.css': 'virtual:uno.css',
},
},
plugins: [
UnoCSS({
mode: 'global',
inspector: false,
}),
react({
babel: {
plugins: [
['babel-plugin-react-compiler', {}],
],
},
}),
wasm(),
],
build: {
outDir: '../dist',
target: process.env.TAURI_PLATFORM === 'windows'
? 'chrome105'
: 'safari16',
minify: isDev || isTauriDebug ? false : 'esbuild',
esbuild: isDev || isTauriDebug
? {}
: {
drop: ['debugger'],
pure: ['console.log', 'console.info', 'console.debug'],
},
sourcemap: isDev || isTauriDebug,
cssCodeSplit: true,
rollupOptions: {
input: (() => {
const inputs = {
main: resolve(__dirname, 'src/windows/main/index.html'),
settings: resolve(__dirname, 'src/windows/settings/index.html'),
quickpaste: resolve(__dirname, 'src/windows/quickpaste/index.html'),
community: resolve(__dirname, 'src/windows/community/index.html'),
textEditor: resolve(__dirname, 'src/windows/textEditor/index.html'),
contextMenu: resolve(__dirname, 'src/plugins/context_menu/contextMenu.html'),
inputDialog: resolve(__dirname, 'src/plugins/input_dialog/inputDialog.html'),
pinImage: resolve(__dirname, 'src/windows/pinImage/pinImage.html'),
preview: resolve(__dirname, 'src/windows/preview/index.html'),
transferShelf: resolve(__dirname, 'src/windows/transferShelf/index.html'),
receiveBox: resolve(__dirname, 'src/windows/receiveBox/index.html'),
updater: resolve(__dirname, 'src/windows/updater/index.html'),
}
const screenshotPath = resolve(__dirname, 'src/windows/screenshot/index.html')
if (!isCommunity && existsSync(screenshotPath)) {
inputs.screenshot = screenshotPath
}
return inputs
})(),
output: {
assetFileNames: 'assets/[name]-[hash][extname]',
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
manualChunks(id) {
if (id.includes('node_modules')) return 'vendor'
if (id.includes('/shared/') || id.includes('\\shared\\')) return 'shared'
return undefined
},
},
},
},
})