fix hot reload on dev server

This commit is contained in:
AI Christianson 2025-03-14 10:25:22 -04:00
parent fe3984329d
commit 07c6c2e5b5
3 changed files with 31 additions and 12 deletions

View File

@ -2,11 +2,12 @@
"name": "@ra-aid/common",
"version": "1.0.0",
"private": true,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "src/index.ts",
"types": "src/index.ts",
"scripts": {
"build": "tsc && postcss src/styles/global.css -o dist/styles/global.css",
"dev": "concurrently \"tsc --watch\" \"postcss src/styles/global.css -o dist/styles/global.css --watch\""
"dev": "concurrently \"tsc --watch\" \"postcss src/styles/global.css -o dist/styles/global.css --watch\"",
"prepare": "npm run build"
},
"dependencies": {
"@radix-ui/react-collapsible": "^1.1.3",

View File

@ -18,9 +18,6 @@ export * from './components/TimelineFeed';
export * from './components/SessionDrawer';
export * from './components/SessionSidebar';
// Export the main screen component
export * from './components/DefaultAgentScreen';
// Export the hello function (temporary example)
export const hello = (): void => {
console.log("Hello from @ra-aid/common");

View File

@ -3,23 +3,44 @@ import react from '@vitejs/plugin-react';
import path from 'path';
export default defineConfig({
plugins: [react()],
plugins: [
react(),
],
resolve: {
// Ensure that Vite treats symlinked packages as local, so HMR works correctly.
// Point to the source files instead of dist for development
alias: {
'@ra-aid/common': path.resolve(__dirname, '../common/dist')
'@ra-aid/common': path.resolve(__dirname, '../common/src')
}
},
optimizeDeps: {
// Force Vite to include these dependencies in its optimization
include: ['@ra-aid/common'],
// Tell Vite to respect our aliased packages instead of using node_modules for them
esbuildOptions: {
preserveSymlinks: true,
}
},
server: {
hmr: {
// More verbose logging for HMR
overlay: true,
},
watch: {
// Watch for changes in the common package.
// This pattern forces Vite to notice file changes in the shared library.
paths: ['../common/src/**', '../common/dist/**']
// Watch for changes in the common package
paths: ['../common/src/**'],
// Ensure changes in source files trigger a reload
usePolling: true,
}
},
css: {
// PostCSS configuration is loaded from postcss.config.js
// This ensures proper processing of Tailwind directives
devSourcemap: true,
},
build: {
// When building for production, we need to make sure the common package is built too
commonjsOptions: {
transformMixedEsModules: true,
},
}
});