-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
179 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,18 +73,12 @@ If you prefer to install the adapter manually instead, complete the following tw | |
|
||
You can deploy to different targets: | ||
|
||
* `edge`: SSR inside an [Edge function](https://vercel.com/docs/concepts/functions/edge-functions). | ||
* `serverless`: SSR inside a [Node.js function](https://vercel.com/docs/concepts/functions/serverless-functions). | ||
* `static`: generates a static website following Vercel's output formats, redirects, etc. | ||
|
||
:::note | ||
deploying to the Edge has [its limitations](https://vercel.com/docs/concepts/functions/edge-functions#known-limitations). An edge function can't be more than 1 MB in size and they don't support native Node.js APIs, among others. | ||
::: | ||
|
||
You can change where to target by changing the import: | ||
|
||
```js | ||
import vercel from '@astrojs/vercel/edge'; | ||
import vercel from '@astrojs/vercel/serverless'; | ||
import vercel from '@astrojs/vercel/static'; | ||
``` | ||
|
@@ -107,7 +101,7 @@ To configure this adapter, pass an object to the `vercel()` function call in `as | |
### analytics | ||
|
||
**Type:** `boolean`<br/> | ||
**Available for:** Serverless, Edge, Static<br/> | ||
**Available for:** Serverless, Static<br/> | ||
**Added in:** `@astrojs/[email protected]` | ||
|
||
You can enable [Vercel Analytics](https://vercel.com/analytics) (including Web Vitals and Audiences) by setting `analytics: true`. This will inject Vercel’s tracking scripts into all your pages. | ||
|
@@ -128,7 +122,7 @@ export default defineConfig({ | |
### imagesConfig | ||
|
||
**Type:** `VercelImageConfig`<br/> | ||
**Available for:** Edge, Serverless, Static | ||
**Available for:** Serverless, Static | ||
**Added in:** `@astrojs/[email protected]` | ||
|
||
Configuration options for [Vercel's Image Optimization API](https://vercel.com/docs/concepts/image-optimization). See [Vercel's image configuration documentation](https://vercel.com/docs/build-output-api/v3/configuration#images) for a complete list of supported parameters. | ||
|
@@ -151,7 +145,7 @@ export default defineConfig({ | |
### imageService | ||
|
||
**Type:** `boolean`<br/> | ||
**Available for:** Edge, Serverless, Static | ||
**Available for:** Serverless, Static | ||
**Added in:** `@astrojs/[email protected]` | ||
|
||
When enabled, an [Image Service](/en/reference/image-service-reference/) powered by the Vercel Image Optimization API will be automatically configured and used in production. In development, a built-in Squoosh-based service will be used instead. | ||
|
@@ -192,7 +186,7 @@ import astroLogo from '../assets/logo.png'; | |
### includeFiles | ||
|
||
**Type:** `string[]`<br/> | ||
**Available for:** Edge, Serverless | ||
**Available for:** Serverless | ||
|
||
Use this property to force files to be bundled with your function. This is helpful when you notice missing files. | ||
|
||
|
@@ -209,10 +203,6 @@ export default defineConfig({ | |
}); | ||
``` | ||
|
||
:::note | ||
When building for the Edge, all the dependencies get bundled in a single file to save space. **No extra file will be bundled**. So, if you *need* some file inside the function, you have to specify it in `includeFiles`. | ||
::: | ||
|
||
### excludeFiles | ||
|
||
**Type:** `string[]`<br/> | ||
|
@@ -233,9 +223,11 @@ export default defineConfig({ | |
}); | ||
``` | ||
|
||
### Per-page functions | ||
### Function bundling configuration | ||
|
||
The Vercel adapter builds to a single function by default. Astro 2.7 added support for splitting your build into separate entry points per page. If you use this configuration the Vercel adapter will generate a separate function for each page. This can help reduce the size of each function so they are only bundling code used on that page. | ||
The Vercel adapter splits builds into a separate function per route by default. This helps reduce the size of each function, as it only bundles code used on that page. | ||
|
||
You can disable this and build to a single function by setting the `functionPerRoute` configuration option to `false`: | ||
|
||
```js | ||
// astro.config.mjs | ||
|
@@ -244,10 +236,9 @@ import vercel from '@astrojs/vercel/serverless'; | |
|
||
export default defineConfig({ | ||
output: 'server', | ||
adapter: vercel(), | ||
build: { | ||
split: true, | ||
}, | ||
adapter: vercel({ | ||
functionPerRoute: false, | ||
}), | ||
}); | ||
``` | ||
|
||
|
@@ -286,18 +277,17 @@ You can use Vercel Edge middleware to intercept a request and redirect before se | |
|
||
The `@astrojs/vercel/serverless` adapter can automatically create the Vercel Edge middleware from an Astro middleware in your code base. | ||
|
||
This is an opt-in feature, and the `build.excludeMiddleware` option needs to be set to `true`: | ||
This is an opt-in feature, and the `edgeMiddleware` option needs to be set to `true`: | ||
|
||
```js | ||
// astro.config.mjs | ||
import { defineConfig } from 'astro/config'; | ||
import vercel from '@astrojs/vercel'; | ||
export default defineConfig({ | ||
output: 'server', | ||
adapter: vercel(), | ||
build: { | ||
excludeMiddleware: true, | ||
}, | ||
adapter: vercel({ | ||
edgeMiddleware: true, | ||
}), | ||
}); | ||
``` | ||
|
||
|