Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: disable serving static assets by default #585

Closed
2 tasks
brandonroberts opened this issue Aug 2, 2023 · 6 comments · Fixed by #663
Closed
2 tasks

Feature: disable serving static assets by default #585

brandonroberts opened this issue Aug 2, 2023 · 6 comments · Fixed by #663

Comments

@brandonroberts
Copy link
Member

Which scope/s are relevant/related to the feature request?

vite-plugin-nitro

Information

One issue we keep coming across is the / route not being pre-rendered. This is because there is an index.html in the client build, and Nitro uses this for serving when pre-rendering.

The workaround is to set serveStatic: false in the Nitro config.

This change would set the flag to false by default, as normal assets would be published to the deployment providers CDN, and not served through the Nitro server.

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@goetzrobin
Copy link
Member

I can take this @brandonroberts

@brandonroberts
Copy link
Member Author

Thanks @goetzrobin. Need to think on this one more.

This would be a breaking change unless we write some migrations to set it to true for existing projects.

Also it might break the usage of $fetch for static assets

@goetzrobin
Copy link
Member

Then I cannot take this 😄 Thanks for pointing that out!

@geromegrignon
Copy link
Contributor

geromegrignon commented Sep 14, 2023

It might not fit all use cases but I'm mitigating it currently by setting min-height: 100vh on the router-outlet as a workaround as it really impacts the CLS score.

@brandonroberts
Copy link
Member Author

One solution is to delete the index.html at the root of the / route is included in the pre-rendered routes array, as we inline the contents of the index.html before pre-rendering.

Then we would render the index.html in the public assets directory.

@brandonroberts
Copy link
Member Author

This fix has been released in version 0.2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants