-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.web.ts
More file actions
51 lines (50 loc) · 1.48 KB
/
vite.config.web.ts
File metadata and controls
51 lines (50 loc) · 1.48 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { resolve } from 'path';
/**
* Web build target (deploy to Cloudflare Pages).
*
* This is intentionally separate from the extension builds:
* - Uses a normal site base path (`/`)
* - Outputs to `dist-web/`
* - Aliases `webextension-polyfill` to a browser-safe shim
*/
export default defineConfig({
// In dev mode, Vite serves `${root}/index.html` at `/`.
// Our web entry lives under src/web, so set root accordingly.
root: resolve(__dirname, 'src/web'),
plugins: [react(), nodePolyfills({ protocolImports: true })],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
// Some deps (e.g. @cosmjs/*) expect Node's crypto; use browser polyfill for web.
crypto: 'crypto-browserify',
'webextension-polyfill': resolve(__dirname, './src/platform/webextension-polyfill-web.ts'),
},
},
define: {
global: 'globalThis',
'process.env': {},
// Build-time constant to distinguish web app from extension
__IS_WEB_BUILD__: JSON.stringify(true),
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
publicDir: resolve(__dirname, 'public-web'),
build: {
outDir: resolve(__dirname, 'dist-web'),
emptyOutDir: true,
rollupOptions: {
input: {
web: resolve(__dirname, 'src/web/index.html'),
},
},
},
base: '/',
});