originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.39k stars 241 forks source link

Images are not loading from Remote App #614

Closed RXJ966 closed 4 months ago

RXJ966 commented 4 months ago

Versions

Reproduction:

I have created two ReactJs apps i.e., host app(shell) and Remote app using latest React + Vite + Typescript. When I open the application, able to view the images from the host app but the remote app is not showing the images.

When I build the app, images are placed in the dist/assets folder but when I inspect the browser source tab, it is not loading the images.

jonick commented 4 months ago

I have the same issue. On the module side, I use the following configuration:

federation({ name: 'module1', filename: 'remoteEntry.js', exposes: { './RemoteComponent': './src/components/RemoteComponent.vue', }, shared: ['vue'] }); On the container side, I configure it like this:

federation({ name: 'core', remotes: { module1: 'http://localhost:3001/assets/remoteEntry.js', }, shared: ['vue'] });

When I launch both applications, I get the following: in conosle http://localhost:3001/assets/remoteEntry.js 404 Not Found

If I specify:

remotes: { module1: 'http://localhost:3001/dist/assets/remoteEntry.js', } It works, but changes are not reflected during development, even with vite build --watch. I still don't understand which path to specify in remotes?

RXJ966 commented 4 months ago

Issue has been resolved, I was using just App instead of App.tsx in the expose. So, updated the below configuration and it is working as expected.

Incorrect syntax

        exposes: {
          './App': './src/App'
        },

Correct syntax

 exposes: {
          './App': './src/App.tsx'
 },