Skip to content

Why federation cannot be used in Vite+Vue3 #264

Answered by gyt95
gyt95 asked this question in Q&A
Discussion options

You must be logged in to vote

I finally found the answer.

My previous execution steps were like this:

// webapp1 - exposes
pnpm build
pnpm dev

// webapp2 - remotes
pnpm dev

But in fact, a core of module federation is that the modules it calls remotely are from the production environment. So even for local development, a static web server should be started so that remote modules can be introduced.

Therefore, the reliance is on the vite preview command, which will start a static web server locally with the dist folder running at http://localhost:4173 . In this way, check whether the build product is available normally in the local environment.

So I added a new command preview: "vite preview", and in vite.config.ts of …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gyt95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant