-
Notifications
You must be signed in to change notification settings - Fork 522
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: 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. |
src/utils/index.ts
Outdated
export function detectTarget() { | ||
return autodetectableProviders[provider]; | ||
} | ||
|
||
// TODO: update when https://github.com/unjs/nitro/pull/1072 merges | ||
export function detectStaticTarget() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that but we need the resolved options first, and detectTarget
is called beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean not all options but detect conditions which for now is only static
(practically merging two utils into one)
src/presets/vercel.ts
Outdated
@@ -126,12 +126,33 @@ export const vercelEdge = defineNitroPreset({ | |||
}, | |||
}); | |||
|
|||
export const vercelStatic = defineNitroPreset({ | |||
extends: "node", | |||
entry: "#internal/nitro/entries/nitro-prerenderer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -149,7 +148,7 @@ export async function loadOptions( | |||
options.preset = | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still prefer top-level static? very happy to change it if, on reflection, you feel that's the best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-static
andnetlify-static
presets 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: false
or otherwise configure this (which they can easily do if user is running some kind ofgenerate
command). But with that, we can then automatically enable provider-specific configuration for zero-config 'static+' deploys.π Checklist