emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
116 stars 15 forks source link

Vite 5 - 404 on scripts when using base #61

Closed renataogarcia closed 6 months ago

renataogarcia commented 8 months ago

When I upgrade to Vite 5, I get a 404 on scripts if base option is in use.

I've done some investigation, and found that what is causing the issue is likely to be this change on vite https://github.com/vitejs/vite/pull/5657.

After the plugin calls transformHtml it changes:

<script type="module">
      console.log("TESTING")
</script>

into:

<script type="module" src="/@id/__x00__/myBase/test.html?html-proxy&index=0.js" />

This used to work before 5657, but now is no longer supported. Vite expects it to have the base in the url as below, otherwise it fails with 404:

<script type="module" src="/myBase/@id/__x00__/myBase/test.html?html-proxy&index=0.js" />

I've tested without using the template and it works fine as it resolves to:

<script type="module" src="/myBase/test.html?html-proxy&index=0.js" />

I've done a workaround to replace all ".@id/x00/" and prepend the base and it seems to work fine.

However, I'm not sure if this is a Vite issue, or a issue with the plugin, whether it is calling transformHtml with some missing options or Vite expects it to adjust the module url.

Please let me know your thoughts.

emosheeep commented 8 months ago

This plugin only handles html files you've configured in pages option, unmatched paths will be next() directly and handled by vite. 🤔

renataogarcia commented 8 months ago

Sorry, I wasn't very clear, but the Githubissues.

  • Githubissues is a development platform for aggregating issues.