-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
67 lines (64 loc) · 1.93 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
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { fileURLToPath, URL } from 'node:url'
const mobile = !!/android|ios/.exec(process.env.TAURI_PLATFORM)
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
return {
plugins: [vue(), vueJsx()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
extensions: ['.js', '.json', '.ts', '.tsx'],
},
optimizeDeps: {
include: [
`monaco-editor/esm/vs/language/json/json.worker`,
`monaco-editor/esm/vs/language/css/css.worker`,
`monaco-editor/esm/vs/language/html/html.worker`,
`monaco-editor/esm/vs/language/typescript/ts.worker`,
`monaco-editor/esm/vs/editor/editor.worker`,
],
},
esbuild: {
drop: mode === 'production' ? ['console', 'debugger'] : [],
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
host: mobile ? '0.0.0.0' : true,
port: 1420,
hmr: mobile
? {
protocol: 'ws',
host: '0.0.0.0',
port: 1421,
}
: undefined,
strictPort: true,
proxy: {
'/api': {
target: `http://127.0.0.1:8080`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
// 3. to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ['VITE_', 'TAURI_'],
}
})