-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathvite.renderer.config.ts
50 lines (48 loc) · 1.67 KB
/
vite.renderer.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 type { ConfigEnv, UserConfig } from 'vite';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { pluginExposeRenderer } from './vite.base.config.js';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import vitePluginRequire from 'vite-plugin-require';
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'renderer'>;
const { root, mode, forgeConfigSelf } = forgeEnv;
const name = forgeConfigSelf.name ?? '';
return {
root,
mode,
base: './',
build: {
outDir: `.vite/renderer/${name}`
},
publicDir: './public',
envDir: '.', // Use this dir for env vars, not 'src'.
optimizeDeps: {
// Don't optimize these packages as they contain web workers and WASM files.
// https://github.com/vitejs/vite/issues/11672#issuecomment-1415820673
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
include: [],
// include: ['@powersync/web > js-logger'], // <-- Include `js-logger` when it isn't installed and imported.
},
plugins: [
// @ts-expect-error there is TS issue that doesn't actually affect the runtime
wasm(),
// @ts-expect-error there is TS issue that doesn't actually affect the runtime
topLevelAwait(),
react(),
vitePluginRequire.default(),
pluginExposeRenderer(name)
],
worker: {
format: 'es',
// @ts-expect-error there is TS issue that doesn't actually affect the runtime
plugins: () => [wasm(), topLevelAwait()]
},
resolve: {
preserveSymlinks: true
},
clearScreen: false
} as UserConfig;
});