-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathvite.config.ts
More file actions
84 lines (81 loc) · 2.29 KB
/
vite.config.ts
File metadata and controls
84 lines (81 loc) · 2.29 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
/// <reference types="vitest/config" />
import path from 'node:path'
import griffel from '@griffel/vite-plugin'
import babel from '@rolldown/plugin-babel'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import packageJson from './package.json'
export default defineConfig ((env) => {
const isDev = env.command === 'serve'
const isProd = env.command === 'build'
const isCicd = env.mode === 'cicd'
// Babel options for both griffel and @rollup/plugin-babel
const babelOptions = {
compact: false,
include: ['app\/**\/*.{ts,tsx}'],
exclude: ['**\/node_modules\/**'],
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
],
}
return {
test: {
include: ['app\/**\/*.{test,spec}.?(c|m)[jt]s?(x)'],
},
publicDir: 'public',
build: {
outDir: 'dist',
target: 'baseline-widely-available',
minify: isProd ? 'oxc' : false,
sourcemap: isDev,
},
plugins: [
isProd && griffel({
include: babelOptions.include,
exclude: babelOptions.exclude,
babelOptions: {
compact: babelOptions.compact,
presets: babelOptions.presets,
},
}),
react(),
babel({
...babelOptions,
}),
],
define: {
__CICD__: `${isCicd}`,
__APP_NAME__: `"${packageJson.displayName}"`,
__APP_VERSION__: `"${packageJson.version}"`,
__APP_DESCRIPTION__: `"${packageJson.description}"`,
__APP_AUTHOR__: `"${packageJson.author}"`,
__APP_HOMEPAGE__: `"${packageJson.homepage}"`,
__APP_REPOSITORY__: `"${packageJson.repository}"`,
__APP_ISSUES__: `"${packageJson.bugs}"`,
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias: {
'@': path.resolve(__dirname, 'app'),
},
},
// 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: {
port: 1420,
strictPort: true,
hmr: {
protocol: 'ws',
port: 1421,
},
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ['**/tauri/**'],
},
},
}
})