You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.5 KiB
92 lines
2.5 KiB
/**
|
|
* @file vite.config.web.mts
|
|
* @description Vite configuration for web platform builds
|
|
*
|
|
* This configuration file defines how the application is built for web platforms.
|
|
* It extends the base configuration with web-specific settings and optimizations.
|
|
*
|
|
* Build Process Integration:
|
|
* 1. Configuration Loading:
|
|
* - Loads environment variables based on build mode
|
|
* - Merges base configuration from vite.config.common.mts
|
|
* - Loads application-specific configuration
|
|
*
|
|
* 2. Platform Definition:
|
|
* - Sets VITE_PLATFORM environment variable to 'web'
|
|
* - Used by PlatformServiceFactory to load web-specific implementations
|
|
*
|
|
* 3. Build Output:
|
|
* - Outputs to 'dist/web' directory
|
|
* - Creates vendor chunk for Vue-related dependencies
|
|
* - Enables PWA features with auto-update capability
|
|
*
|
|
* 4. Development vs Production:
|
|
* - Development: Enables source maps and development features
|
|
* - Production: Optimizes chunks and enables PWA features
|
|
*
|
|
* Usage:
|
|
* - Development: npm run dev
|
|
* - Production: npm run build:web
|
|
*
|
|
* @see vite.config.common.mts
|
|
* @see vite.config.utils.mts
|
|
* @see PlatformServiceFactory.ts
|
|
*/
|
|
|
|
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import baseConfig from "./vite.config.base";
|
|
|
|
// Define Node.js built-in modules that need browser compatibility
|
|
const nodeBuiltins = {
|
|
stream: 'stream-browserify',
|
|
util: 'util',
|
|
crypto: 'crypto-browserify',
|
|
http: 'stream-http',
|
|
https: 'https-browserify',
|
|
zlib: 'browserify-zlib',
|
|
url: 'url',
|
|
assert: 'assert',
|
|
path: 'path-browserify',
|
|
fs: 'browserify-fs',
|
|
tty: 'tty-browserify'
|
|
};
|
|
|
|
export default defineConfig({
|
|
...baseConfig,
|
|
plugins: [vue()],
|
|
optimizeDeps: {
|
|
...baseConfig.optimizeDeps,
|
|
include: [...(baseConfig.optimizeDeps?.include || []), 'qrcode.vue'],
|
|
exclude: Object.keys(nodeBuiltins),
|
|
esbuildOptions: {
|
|
define: {
|
|
global: 'globalThis'
|
|
}
|
|
}
|
|
},
|
|
resolve: {
|
|
...baseConfig.resolve,
|
|
alias: {
|
|
...baseConfig.resolve?.alias,
|
|
...nodeBuiltins
|
|
}
|
|
},
|
|
build: {
|
|
...baseConfig.build,
|
|
commonjsOptions: {
|
|
...baseConfig.build?.commonjsOptions,
|
|
include: [/node_modules/],
|
|
exclude: [/src\/services\/platforms\/electron/],
|
|
transformMixedEsModules: true
|
|
},
|
|
rollupOptions: {
|
|
...baseConfig.build?.rollupOptions,
|
|
external: Object.keys(nodeBuiltins),
|
|
output: {
|
|
...baseConfig.build?.rollupOptions?.output,
|
|
globals: nodeBuiltins
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|