messenger/codebase/web/vite.config.ts
Claude Code 0afa44c9ca chore(web): 🔧 Update Vite build configuration for frontend optimizations
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-07 13:42:22 -07:00

114 lines
2.9 KiB
TypeScript

import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { defineConfig, type Plugin } from 'vite';
function handleDtsImports(): Plugin {
return {
name: 'handle-dts-imports',
enforce: 'pre',
resolveId(id) {
if (id.endsWith('.d.ts')) {
return { id: '\0empty-module', moduleSideEffects: false };
}
return null;
},
load(id) {
if (id === '\0empty-module') {
return 'export default {}';
}
return null;
},
};
}
export default defineConfig({
plugins: [handleDtsImports(), react()],
base: './',
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@lilith/messenger-ui': resolve(__dirname, '../packages/messenger-ui/src/index.ts'),
'@lilith/ui-messaging': resolve(
__dirname,
'./node_modules/@lilith/ui-messaging/src/index.ts',
),
'@lilith/ui-feedback': resolve(
__dirname,
'./node_modules/@lilith/ui-feedback/src/index.ts',
),
'@lilith/ui-zname': resolve(
__dirname,
'./node_modules/@lilith/ui-zname/dist/index.js',
),
'styled-components': resolve(__dirname, './node_modules/styled-components'),
},
dedupe: [
'react',
'react-dom',
'styled-components',
'@tanstack/react-query',
'@lilith/ui-theme',
'@lilith/ui-primitives',
],
},
optimizeDeps: {
esbuildOptions: {
plugins: [
{
name: 'ignore-dts-imports',
setup(build) {
build.onResolve({ filter: /\.d\.ts$/ }, () => ({
path: 'empty-module',
namespace: 'ignore-dts',
}));
build.onLoad({ filter: /.*/, namespace: 'ignore-dts' }, () => ({
contents: 'export default {}',
loader: 'js',
}));
},
},
],
},
},
server: {
port: 5174,
proxy: {
'/api/browse': {
target: 'http://localhost:3100',
changeOrigin: true,
},
'/api/review-queue': {
target: 'http://localhost:3100',
changeOrigin: true,
},
'/api/autoresponder-config': {
target: 'http://localhost:3100',
changeOrigin: true,
},
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
onwarn(warning, warn) {
// Suppress "is not exported by __vite-browser-external" warnings from
// @lilith/text-processing-utils — it imports Node builtins (fs, path,
// fs/promises) that Vite stubs in browser builds. The code paths using
// these are never reached in the browser.
if (
warning.code === 'MISSING_EXPORT' &&
typeof warning.exporter === 'string' &&
warning.exporter.includes('__vite-browser-external')
) {
return;
}
warn(warning);
},
},
},
});