Replies: 1 comment 1 reply
-
|
This is for module federation / micro-frontends right? You want absolute URLs so other apps can import from your dev server. Solution: Use the // vite.config.js
export default defineConfig({
base: 'http://127.0.0.1:8001/',
server: {
port: 8001,
cors: true, // Important for cross-origin imports
}
})For dev only, use conditional base: export default defineConfig(({ mode }) => ({
base: mode === 'development'
? 'http://127.0.0.1:8001/'
: '/',
server: {
port: 8001,
cors: true,
}
}))If you need module federation specifically: Check out npm i @originjs/vite-plugin-federationimport federation from '@originjs/vite-plugin-federation'
export default defineConfig({
plugins: [
federation({
name: 'app1',
filename: 'remoteEntry.js',
exposes: {
'./Module1': './src/module1/index.ts',
},
})
]
})This way other projects can import your modules dynamically at runtime. Hope this helps! Let me know if you need more details on the federation setup. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My code:
The compiled content as seen by the browser:
I want these modules to add the origin of the development server when in the development mode.
The purpose is to achieve a function similar to the combination of multiple projects.
What should I do to make my idea come true? I'm asking the experts in the community to teach me.
Beta Was this translation helpful? Give feedback.
All reactions