Vite.NET icon indicating copy to clipboard operation
Vite.NET copied to clipboard

ProductionViteSpaScripts.cshtml path fixes.

Open hdimon opened this issue 2 years ago • 3 comments

Some issue in paths for css and scripts in ProductionViteSpaScripts.cshtml.

How did I find it:

  • For the sake of test I created SPA with root in https://localhost:7104/admin/, but from my understanding it's not needed to have even SPA located in nested address, it's enough just to create any nested page in single SPA, for example https://localhost:7104/users/profile. Of course it's needed to setup Fallback like app.MapFallbackToPage("/{*catchall}", "/Index") . Now when you go to this address and refresh page then page is opened but scripts are not loaded because they are tried to be loaded from addresses like: https://localhost:7104/admin/AdminApp/main.228761a0.js https://localhost:7104/admin/AdminApp/main.951a8be3.css i.e. file paths are relative to current address (https://localhost:7104/admin/) instead of root (https://localhost:7104/). Correct paths are: https://localhost:7104/AdminApp/main.228761a0.js https://localhost:7104/AdminApp/main.951a8be3.css

Changes are supposed to fix it. Honestly I'm not 100% sure that it's fully correct fix for all environments. I had idea to use Environment.WebRootPath but have doubts (there was mix of forward slashes and backslashes). So if you see more appropriate way to fix that then please do:).

hdimon avatar Nov 12 '23 17:11 hdimon

Please publish new version of Nuget and NPM packages when you have time - it's really needed.

hdimon avatar Nov 24 '23 20:11 hdimon

I just created a new version of both the nuget and npm packages.

On Fri, Nov 24, 2023, 2:32 PM hdimon @.***> wrote:

Please publish new version of Nuget and NPM packages when you have time - it's really needed.

— Reply to this email directly, view it on GitHub https://github.com/techgems/Vite.NET/pull/21#issuecomment-1826067581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEBJ7ALOGB4TJSFB4QGOXVTYGD77JAVCNFSM6AAAAAA7IFBIGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGA3DONJYGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

techgems avatar Nov 25 '23 14:11 techgems

Thank you!

hdimon avatar Nov 25 '23 20:11 hdimon