module-federation-examples
module-federation-examples copied to clipboard
fix(routing): not found main.js & remoteEntry.js
If landing on a "deep" route path like /profile/foo/bar, main.js and remoteEntry.js assets are not found.
The problem is that script tags src in the HTML are not absolute (main.js instead of /main.js).
This can be solved by either:
- change
publicPathfromautoto a "hard-coded" URL (ie. http://localhost:3001/). - use
HashRouter.
Is there any better solution?
Yes!
change publicPath in html-webpack-plugin to be /.
This works just fine for me.
I know, it might be a problem with how html-webpack-plugin treat auto.
Until we find out if it is, and create a PR, this is not a bad workaround :)