Open
Description
Under normal circumstances, the reference paths for resource files built by a plugin should align with the base path specified in the Vite config.
The filename of the exposed remote module usually doesn't include a hash because it's the entry point for remote modules and needs to be accessible by external applications. Therefore, it is typically deployed separately on Nginx, while other resources are placed on a CDN. If a relative path is used, it can cause a bug where files can't be found.
vite.config.js
import { federation } from '@module-federation/vite'
export default {
base: 'https://cdn.example.com/project-name',
...
plugins: [
federation({
name: 'remote',
filename: 'remote.js',
exposes: {
'./preload': './src/preload',
},
shared: [],
}),
],
}
output remote.js
![image](https://private-user-images.githubusercontent.com/7956480/393775215-56ef72d8-a13a-4b3d-ad32-82265b090d49.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTQ2MzIsIm5iZiI6MTczOTM1NDMzMiwicGF0aCI6Ii83OTU2NDgwLzM5Mzc3NTIxNS01NmVmNzJkOC1hMTNhLTRiM2QtYWQzMi04MjI2NWIwOTBkNDkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDk1ODUyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGViN2EyNjVlMWY3ZTc2OTU3ZDc3ZDdlYzg0MjU1MTNlZmQxZjJlNmM3MWY3OTdiMGQzZTU0OTk4YjczYzZlYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.-QpPgAR8MfTmMHDrGr-LeQyhFNpbH3uTSw4BLgLxslA)
Metadata
Assignees
Labels
No labels