96 lines
3.5 KiB
TypeScript
96 lines
3.5 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
import { platformVite } from '@lilith/build-core';
|
|
import { versionPlugin } from '../../../@packages/@utils/vite-version-plugin/src';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
platformVite({ allowedHosts: ['.local'] }),
|
|
versionPlugin({ appName: 'Platform Analytics (Stakeholder)' }),
|
|
],
|
|
server: {
|
|
// Port from infrastructure/ports.yaml: features.platform-analytics.frontend-dev
|
|
port: parseInt(process.env.VITE_PORT || '5110', 10),
|
|
host: process.env.VITE_HOST || '0.0.0.0',
|
|
strictPort: true,
|
|
open: false,
|
|
hmr: {
|
|
host: process.env.VITE_HMR_HOST || 'analytics.atlilith.local',
|
|
port: parseInt(process.env.VITE_HMR_PORT || '5110', 10),
|
|
protocol: process.env.VITE_HMR_PROTOCOL || 'http',
|
|
},
|
|
proxy: {
|
|
'/api': {
|
|
// Analytics API backend (port from infrastructure/ports.yaml)
|
|
target: process.env.VITE_API_URL || 'http://localhost:4110',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
fs: {
|
|
// Allow serving files from pnpm workspace
|
|
allow: ['..'],
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
// Deduplicate styled-components to prevent dual-instance ThemeProvider breakage
|
|
'styled-components': path.resolve(__dirname, '../../../node_modules/styled-components'),
|
|
// @lilith/api-client: source-only package (no build step, exports from src)
|
|
'@lilith/api-client': path.resolve(__dirname, '../../../@packages/@infrastructure/api-client/src'),
|
|
// lucide-react: fix dangling bun store symlink by resolving directly to bun store
|
|
// The workspace symlink for lucide-react points to a stale bun store hash
|
|
'lucide-react': path.resolve(__dirname, '../../../../node_modules/.bun/lucide-react@0.553.0+b1ab299f0a400331/node_modules/lucide-react'),
|
|
'@': path.resolve(__dirname, './src'),
|
|
'@packages': path.resolve(__dirname, '../../../@packages'),
|
|
'@features/i18n': path.resolve(__dirname, '../../i18n'),
|
|
// @ui/* aliases - map to installed @lilith/ui-* packages from registry
|
|
'@ui/theme': '@lilith/ui-theme',
|
|
'@ui/themes': '@lilith/ui-themes',
|
|
'@ui/accessibility': '@lilith/ui-accessibility',
|
|
'@ui/navigation': '@lilith/ui-navigation',
|
|
'@ui/primitives': '@lilith/ui-primitives',
|
|
'@ui/layout': '@lilith/ui-layout',
|
|
'@ui/typography': '@lilith/ui-typography',
|
|
'@ui/feedback': '@lilith/ui-feedback',
|
|
'@ui/data': '@lilith/ui-data',
|
|
'@ui/forms': '@lilith/ui-forms',
|
|
'@ui/charts': '@lilith/ui-charts',
|
|
'@ui/analytics': '@lilith/ui-analytics',
|
|
'@ui/utils': '@lilith/ui-utils',
|
|
'@ui/design-tokens': '@lilith/ui-design-tokens',
|
|
'@ui/error-pages': '@lilith/ui-error-pages',
|
|
'@ui/icons': '@lilith/ui-icons',
|
|
'@ui/header': '@lilith/ui-header',
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
exclude: [
|
|
// Test-only packages — never pre-bundle in browser context
|
|
'msw',
|
|
'@mswjs/interceptors',
|
|
'@lilith/test-utils',
|
|
],
|
|
esbuildOptions: {
|
|
// Ignore .d.ts imports (some @lilith/ui-* packages incorrectly import them)
|
|
plugins: [{
|
|
name: 'ignore-dts-imports',
|
|
setup(build) {
|
|
build.onResolve({ filter: /\.d\.ts$/ }, (args) => ({
|
|
path: args.path,
|
|
namespace: 'empty-dts',
|
|
}));
|
|
build.onLoad({ filter: /.*/, namespace: 'empty-dts' }, () => ({
|
|
contents: '',
|
|
loader: 'js',
|
|
}));
|
|
}
|
|
}]
|
|
}
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
},
|
|
});
|