forked from surrealdb/surrealist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
56 lines (49 loc) · 1.42 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
import react from '@vitejs/plugin-react';
import { defineConfig, PluginOption } from 'vite';
import { readFileSync, cpSync, existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const { version, author, surreal } = JSON.parse(readFileSync('./package.json', 'utf8'));
function pages(): PluginOption {
return {
name: 'github-pages',
writeBundle() {
const from = fileURLToPath(new URL('dist/index.html', import.meta.url));
const to = fileURLToPath(new URL('dist/404.html', import.meta.url));
cpSync(from, to);
}
};
}
const generatedDir = fileURLToPath(new URL('src/generated', import.meta.url));
if (!existsSync(generatedDir)) {
throw new Error('Surrealist embed generated files not found. Run `pnpm embed:build` to generate them.');
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), pages()],
clearScreen: false,
envPrefix: ['VITE_', 'TAURI_'],
server: {
port: 1420,
strictPort: true
},
build: {
target: process.env.TAURI_PLATFORM == 'windows' ? 'chrome105' : 'safari13',
minify: process.env.TAURI_DEBUG ? false : 'esbuild',
sourcemap: !!process.env.TAURI_DEBUG,
},
resolve: {
alias: {
'~': fileURLToPath(new URL('src', import.meta.url))
}
},
css: {
modules: {
localsConvention: 'dashesOnly'
}
},
define: {
'import.meta.env.VERSION': `"${version}"`,
'import.meta.env.AUTHOR': `"${author}"`,
'import.meta.env.SDB_VERSION': `"${surreal}"`,
}
});