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

feat(netlify): use new @netlify/vite-plugin-react-router #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

serhalp
Copy link

@serhalp serhalp commented Dec 17, 2024

See https://github.com/netlify/remix-compute/tree/main/packages/vite-plugin-react-router.

This removes all the custom Netlify stuff from the template except the netlify.toml and the Vite plugin. 🎉

Comment on lines -9 to -14
# Set immutable caching for static files, because they have fingerprinted filenames

[[headers]]
for = "/assets/*"
[headers.values]
"Cache-Control" = "public, max-age=31560000, immutable"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed, since these assets are in the publish dir (build/client) and uploaded to the CDN at deploy time and served statically

@TrySound
Copy link

I get this error

> react-router dev

Error: Could not determine server runtime. Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.

@serhalp serhalp force-pushed the feat/simplify-netlify-template branch from e3735ef to dedf7c7 Compare December 19, 2024 21:02
@serhalp
Copy link
Author

serhalp commented Dec 19, 2024

Thank you @TrySound! It looks like I went a bit overboard with removing unused dependencies. It should be fixed now!


export default async (request: Request, context: Context) => {
return requestHandler(request, {
VALUE_FROM_NETLIFY: "Hello from Netlify",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALUE_FROM_NETLIFY is still referenced in app/routes/home.tsx, but now that the server app file has been removed that context isn't getting set anywhere. Part of the value proposition with React Router framework is that it produced a request handler that can be plugged into any server.

With the new approach you are proposing here, how would I define load context like VALUE_FROM_NETLIFY?

Copy link
Author

@serhalp serhalp Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Vite plugin merges the Netlify function context with the app load context (this is copied pretty much as-is from our Remix plugin). You can also see e2e test coverage of this here.

I could be misunderstanding though! Can you give a more concrete example of what a user would be trying to accomplish here?

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 this pull request may close these issues.

3 participants