Zain
Zain

Reputation: 61

How to Share Images Across Packages in Vite Module Federation with React and npm Workspaces?

I am using Vite module federation with npm workspaces in a monorepo setup.

I have two packages, both named header. In the header package, I use an image that is publicly served by that package. When I preview or build the header package, the image displays correctly. However, when I consume the header component in the shell application, the image is missing because it is not publicly served by the shell package.

My question is: How can I ensure that any image used by a package is automatically served along with the component, so it works seamlessly when consumed in any other package or application?

Upvotes: 0

Views: 61

Answers (0)

Related Questions