forked from mountain-loop/yaak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
50 lines (47 loc) · 1.36 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
import react from '@vitejs/plugin-react';
import { internalIpV4 } from 'internal-ip';
import { createRequire } from 'node:module';
import path from 'node:path';
import { defineConfig, normalizePath } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import svgr from 'vite-plugin-svgr';
import topLevelAwait from 'vite-plugin-top-level-await';
const require = createRequire(import.meta.url);
const cMapsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
);
const standardFontsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
);
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM ?? '');
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [
svgr(),
react(),
topLevelAwait(),
viteStaticCopy({
targets: [
{ src: cMapsDir, dest: '' },
{ src: standardFontsDir, dest: '' },
],
}),
],
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: mobile ? '0.0.0.0' : false,
hmr: mobile
? {
protocol: 'ws',
host: await internalIpV4(),
port: 1421,
}
: undefined,
watch: {
ignored: ['**/src-tauri/**', '**/designs/**', '**/plugins/**'],
},
},
envPrefix: ['VITE_', 'TAURI_'],
}));