jan/web-app/vite.config.web.ts
Dinh Long Nguyen a30eb7f968
feat: Jan Web (reusing Jan Desktop UI) (#6298)
* add platform guards

* add service management

* fix types

* move to zustand for servicehub

* update App Updater

* update tauri missing move

* update app updater

* refactor: move PlatformFeatures to separate const file

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* change tauri fetch name

* update implementation

* update extension fetch

* make web version run properly

* disabled unused web settings

* fix all tests

* fix lint

* fix tests

* add mock for extension

* fix build

* update make and mise

* fix tsconfig for web-extensions

* fix loader type

* cleanup

* fix test

* update error handling + mcp should be working

* Update mcp init

* use separate is_web_app build property

* Remove fixed model catalog url

* fix additional tests

* fix download issue (event emitter not implemented correctly)

* Update Title html

* fix app logs

* update root tsx render timing

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-05 01:47:46 +07:00

68 lines
2.0 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
export default defineConfig({
plugins: [
TanStackRouterVite({
target: 'react',
autoCodeSplitting: true,
routeFileIgnorePattern: '.((test).ts)|test-page',
}),
react(),
tailwindcss(),
],
build: {
outDir: './dist-web',
emptyOutDir: true,
rollupOptions: {
external: [
// Exclude Tauri packages from web bundle
'@tauri-apps/api',
'@tauri-apps/plugin-http',
'@tauri-apps/plugin-fs',
'@tauri-apps/plugin-shell',
'@tauri-apps/plugin-clipboard-manager',
'@tauri-apps/plugin-dialog',
'@tauri-apps/plugin-os',
'@tauri-apps/plugin-process',
'@tauri-apps/plugin-updater',
'@tauri-apps/plugin-deep-link',
'@tauri-apps/api/event',
'@tauri-apps/api/path',
'@tauri-apps/api/window',
'@tauri-apps/api/webviewWindow',
],
},
target: 'esnext',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
define: {
IS_TAURI: JSON.stringify(process.env.IS_TAURI),
// Platform detection constants for web version
IS_WEB_APP: JSON.stringify(true),
// Disable auto-updater on web (not applicable)
AUTO_UPDATER_DISABLED: JSON.stringify(true),
IS_MACOS: JSON.stringify(false),
IS_WINDOWS: JSON.stringify(false),
IS_LINUX: JSON.stringify(false),
IS_IOS: JSON.stringify(false),
IS_ANDROID: JSON.stringify(false),
PLATFORM: JSON.stringify('web'),
VERSION: JSON.stringify(process.env.npm_package_version || '1.0.0'),
POSTHOG_KEY: JSON.stringify(process.env.POSTHOG_KEY || ''),
POSTHOG_HOST: JSON.stringify(process.env.POSTHOG_HOST || ''),
MODEL_CATALOG_URL: JSON.stringify(process.env.MODEL_CATALOG_URL || ''),
},
server: {
port: 3001,
strictPort: true,
},
})