I’m working on a monorepo project using npm workspaces with the following structure:
monorepo/
apps/web - (Vite React app)
packages/ui - (React components built with tsc, no bundler)
web vite.config.ts
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
optimizeDeps: {
exclude: ["@monorepo/ui"],
},
define: {
"process.env": {},
},
});
The ui package’s package.json:
{
"name": "@monorepo/ui",
"type": "module",
"scripts": {
"dev": "tsc --watch",
"build": "tsc"
},
"exports": {
"./button": {
"default": "./dist/button.js",
"types": "./src/button.tsx"
},
...
}
// home.page.ts of web app
import { Button } from "@monorepo/ui/button";
when I make changes to Button in ui package, the full page reload happens in web app, is there any way to make it make HMR instead ???