feat: add vercel-static and netlify-static presets#1073
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1073 +/- ##
==========================================
- Coverage 67.92% 67.73% -0.19%
==========================================
Files 65 65
Lines 6406 6468 +62
Branches 713 717 +4
==========================================
+ Hits 4351 4381 +30
- Misses 2041 2072 +31
- Partials 14 15 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
Does vercel-static support Vercel serverless functions?From my tests, it seems that currently |
|
No, this PR is purely static and does not render any serverless functions, just static assets, redirects, and headers. |
| } | ||
|
|
||
| // TODO: update when https://github.com/unjs/nitro/pull/1072 merges | ||
| export function detectStaticTarget() { |
There was a problem hiding this comment.
PR mergeed, also refactor, we might support { static }? for detectTarget itself to pas conditions like this without introducing new one
There was a problem hiding this comment.
I considered that but we need the resolved options first, and detectTarget is called beforehand.
There was a problem hiding this comment.
I mean not all options but detect conditions which for now is only static (practically merging two utils into one)
|
|
||
| export const vercelStatic = defineNitroPreset({ | ||
| extends: "node", | ||
| entry: "#internal/nitro/entries/nitro-prerenderer", |
There was a problem hiding this comment.
I'm thinking more how we should approach this. Basing presets on prerenderer is an additional step and needs to be handled by nuxt. Whereas we could simply stop building server with static true.
|
Thanks for the work on this PR @danielroe ❤️ More I'm thinking it would be nice if we (in an initial PR) introduce |
|
Seems good to me! Shall I refactor this PR to include that as well, or would you value a separate PR? |
|
A seperate PR would be nicer if you don't mind ❤️ |
vercel-static presetvercel-static and netlify-static presets
| presetOverride || | ||
| (layers.find((l) => l.config.preset)?.config.preset as string) || | ||
| defaultPreset; | ||
| (detectTarget({ static: !options.build }) ?? "node-server"); |
There was a problem hiding this comment.
I am thinking since we didn't release nitropack yet, would it made sense that we introduced static: boolean flag instead of top level build flag? It is mainly for sake of static support we introduced flag...
There was a problem hiding this comment.
yes, that works 👍 only downside is that it's less accurate - build: false is precisely what the flag does. The rest is enabled only by static presets.
There was a problem hiding this comment.
you still prefer top-level static? very happy to change it if, on reflection, you feel that's the best.
pi0
left a comment
There was a problem hiding this comment.
LGTM. Let's do static option refactor in another change
🔗 Linked issue
resolves #818
also nuxt/image#638, nuxt/image#617, nuxt/image#757
❓ Type of change
📚 Description
This adds new
vercel-staticandnetlify-staticpresets that will use platform features to handle redirects, headers, etc. For Vercel, this will also include Vercel Images config and solve nuxt/image#638.It is not fully auto-detectable - frameworks that use it will need to pass
build: falseor otherwise configure this (which they can easily do if user is running some kind ofgeneratecommand). But with that, we can then automatically enable provider-specific configuration for zero-config 'static+' deploys.📝 Checklist