-
-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathvite.config.ts
More file actions
83 lines (79 loc) · 2.26 KB
/
Copy pathvite.config.ts
File metadata and controls
83 lines (79 loc) · 2.26 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
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools';
import { run } from 'vite-plugin-run';
import { assertNoRestrictedBackgroundSourceImport } from './src/build/background-source-import-guard';
import { rejectTestModulesInProductionBuild } from './src/build/reject-test-modules-in-production-build';
const host = process.env.TAURI_DEV_HOST;
const backgroundSourceImportGuard = {
name: 'background-source-import-guard',
load(id: string) {
assertNoRestrictedBackgroundSourceImport(id);
return null;
},
};
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
backgroundSourceImportGuard,
rejectTestModulesInProductionBuild(),
run([
{
name: 'Sync License Headers',
run: ['npm', 'run', 'sync-license'],
pattern: ['src/**/*.{vue,ts,js}', 'src-tauri/src/**/*.rs'],
},
{
name: 'Sync i18n Files',
run: ['npm', 'run', 'sync-i18n'],
pattern: ['src/localization/messages/en.json'],
},
]),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@shared': fileURLToPath(new URL('./src-shared', import.meta.url)),
},
},
envPrefix: ['VITE_', 'TAURI_ENV_*'],
clearScreen: false, // Prevent vite from obscuring rust errors
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421,
}
: undefined,
watch: {
ignored: ['**/src-tauri/target/**', '**/node_modules/**'],
},
},
build: {
rollupOptions: {
onwarn(warning, defaultHandler) {
if (
typeof warning.message === 'string'
&& warning.message.includes('dynamically imported')
&& warning.message.includes('dynamic import will not move module into another chunk')
) {
return;
}
defaultHandler(warning);
},
},
target:
process.env.TAURI_ENV_PLATFORM == 'windows'
? 'chrome138'
: 'safari17',
minify: !process.env.TAURI_ENV_DEBUG ? 'esbuild' : false,
sourcemap: !!process.env.TAURI_ENV_DEBUG,
},
});