vite icon indicating copy to clipboard operation
vite copied to clipboard

nx requiring additional vite config

Open DanielSegal1 opened this issue 1 year ago • 2 comments

Hi, in the past few days I tried to use the plugin inside my app which is part of an NX monorepo. Unfortunately I got 404 when trying to fetch ..../monorepo/node_modules/__mf__virtual/remote_app_H_A_I_hostAutoInit_H_A_I.js (I cant remember the exact name but it was close to that).

Fiddling around, I realized that because this is an NX monorepo, and the node_modules are located under the whole monorepo and not under the app (where it usually would be), vite doesn't expose it.

I tried some workarounds, and what I found to be working is adding to the vite's config: build: { fs: { allow: ['..../monorepo/node_modules'] } }

My takeaway from this journey is that it either should be solved Inside the plugin itself, or if thats beyond the capabilities, at least add this bit of information to the docs. Would like to hear what you think about it

P.S this app is pretty big with quite a few dependecies (one of the currently is @originjs/vite-plugin-federation) and we've never had this kind of problem

DanielSegal1 avatar Nov 18 '24 20:11 DanielSegal1

@DanielSegal1 thanks for your investigation. We definitely need to add a note in the readme file. I prefer to inform the end user rather than try to cover all the possible configurations. Your case is Nx, but another one is Turborepo, etc. etc. Can I ask you to open a PR for that? Thanks

gioboa avatar Nov 18 '24 20:11 gioboa

Have you set base and server.origin?

zhangHongEn avatar Nov 19 '24 03:11 zhangHongEn

As there's been no activity for 30 days, this issue has been flagged as stale. If you'd like it to remain open, please add a comment within the next 7 days. Thank you.

github-actions[bot] avatar Nov 05 '25 16:11 github-actions[bot]