vite-plugin-vue-inspector
vite-plugin-vue-inspector copied to clipboard
feat: respect vite base path
In some cases when a project stays behind a reverse proxy, the base path needs to be respected when importing virtual modules. This PR fixes that.
Is there anything blocking this PR?
Can you provide a use case about it ? Thanks!
Can you provide a use case about it ? Thanks!
Sure, in a project I am working on, we're using vite with --base /front/ flag on both production and development. It's due to our environment structure.
Our reverse proxy is configured to redirect / to a special backend route and redirect /front/* to the vite server when in development mode. This special backend route renders our frontend app served through vite and does some additional magic.
So basically, vite uses /front/ but is accessed through /. Vue inspector fails to recognize that it should serve its scripts through /front/ and it serves them through /, throwing 404 for us. Since this behavior can be fixed in the plugin itself rather than adding an exception to our reverse proxy configuration, I decided to fix it there :)
Some of the base resolving code is based on vite PWA plugin's code.
I've created similar pull request that got merged in their repo: https://github.com/antfu/vite-plugin-pwa/pull/345
@webfansplz, do you have more questions regarding the usecase? What's your view on merging this PR?
@webfansplz, do you have more questions regarding the usecase? What's your view on merging this PR?
I'm not sure if this change will affect any other use cases, and I prefer to simply provide an option for the user to configure
Is there a point in configuring something twice?
Is there a point in configuring something twice?
The root cause is that we are not quite sure if (! base.match(/^(? :[a-z]+:)? \/\//i) && ! base.startsWith('/') && ! base.startsWith('./')) { will these judge have an impact on other use cases, we need to ensure that they are as flexible and generic as possible.