-
-
Notifications
You must be signed in to change notification settings - Fork 247
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(vite-plugin-nitro): add internal deployment support for Netlify #1202
Conversation
✅ Deploy Preview for analog-blog ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for analog-ng-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thanks @pieh! Can this be zero-config for static assets also? |
With netlify/build#5751 we will soon automatically pre-fill configuration when creating a new site on Netlify web app (once that change actually end up in production), so this flow will be ~somewhat zero conf for static assets soon. For CLI usage ( Netlify doesn't have equivalent to something like Vercel's output api for static assets (https://github.com/analogjs/analog/blob/beta/packages/vite-plugin-nitro/src/lib/vite-plugin-nitro.ts#L354-L356) where there is always specific directory from which static assets are uploaded - Netlify relies on "publish directory" for those things, so instead of frameworks putting those files in deployment specific directory, either user or our framework detection tell us where framework outputs static assets With that said, I think something is not exactly right with either this change or configuration of test Netlify sites/apps because preview deploy for I did attempt to deploy this app on my side of things locally with following configuration (so
and I did get working deploy ( https://66855a09ed43201e349b11f4--analog-app-no-functions-defined-test.netlify.app/api/v1/products ), so some debugging is needed why deploy preview on this PR is not actually working correctly |
I think I have clue given the site settings - the "Package path" is not set here while mine was equivalent to So while I do think it would be beneficial for site to specify "correct" package path, any change in this PR should NOT break the sites with currently working setting, so I'll look if I can figure out setup that would just work for both scenarios with Package Path set and not set. I don't have much Nitro knowledge and the |
...nitroConfig, | ||
output: { | ||
...nitroConfig?.output, | ||
dir: '{{ rootDir }}/.netlify/functions-internal', |
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 think what we need to do here is set the serverDir
. The dir
sets the output for everything else, including the publicDir
and .nitro
build directory.
dir: '{{ rootDir }}/.netlify/functions-internal', | |
serverDir: '{{ rootDir }}/.netlify/functions-internal', |
Yea, I don't usually use the package path because even in a monorepo setup like Nx, I build from the root and use the project path to build where the output goes in the |
@pieh were you able to find anything else on this? |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Users deploying to Netlify need to additionally configure location of produced serverless functions
Closes #
What is the new behavior?
Serverless functions are generated at location that Netlify platform automatically handle removing the need to specify ~custom serverless function directory when configuring deployments to Netlify.
Additional note is that hopefully soon at least non-nx variant would require zero configuration. We recently added Analog to frameworks we automatically detect ( netlify/build#5751 ) which soon will suggest appropiate settings when creating Analog site in Netlify web ui and there is work in-progress to use same detection automatically configure deployment when using Netlify CLI ( netlify/cli#6729 )
Does this PR introduce a breaking change?
Explanation: users defining Netlify Functions directory with current instructions will still be able to deploy successfully because Netlify always look for functions in adjusted directory, so even if we point functions directory to one that no longer exist (or at least doesn't have Analog function) it will work correctly:
Other information
[optional] What gif best describes this PR or how it makes you feel?