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", "name": "@ra-aid/common",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"main": "dist/index.js", "main": "src/index.ts",
"types": "dist/index.d.ts", "types": "src/index.ts",
"scripts": { "scripts": {
"build": "tsc && postcss src/styles/global.css -o dist/styles/global.css", "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": { "dependencies": {
"@radix-ui/react-collapsible": "^1.1.3", "@radix-ui/react-collapsible": "^1.1.3",

View File

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

View File

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