Prepare Astro for Deployment
Install Astro Adapter
Using astro add
To install the Astro adapter and update your astro.config.mjs
, run:
npx astro add @zonke-cloud/astro-adapter
Manual Installation
Install the Astro adapter:
npm install @zonke-cloud/astro-adapter
Update your astro.config.mjs
to include the adapter:
Sample Astro config file
astro.config.mjs
import aws from '@zonke-cloud/astro-adapter';
export default {
output: 'server', // or 'static'
adapter: aws({
target: 'lambda', // or 's3'
serverBundleOptions: {
// Example of excluding modules from the server bundle.
external: ['fsevents', 'sharp', 'lightningcss', 'vite'],
},
}),
};
You should not need the adapter for static deployments, but it will work if you include it.
Configuration Options
-
output
- The output type of the Astro project. Options are:static
- Deploy as a static site.server
- Deploy as a server-rendered site.
-
target
- The target deployment environment. Options are:s3
- Deploy to S3 (behind CloudFront) for static site hosting. Corresponds to thestatic
output type.lambda
- Deploy to S3, CloudFront, and Lambda with SSR support. Corresponds to theserver
output type.EC2
(Coming Soon) - Deploy to S3, CloudFront, and ECS EC2 with SSR support. Corresponds to theserver
output type.Fargate
(Coming Soon) - Deploy to S3, CloudFront, and ECS Fargate with SSR support. Corresponds to theserver
output type.
-
serverBundleOptions
(optional) - Used to bundle the server code for SSR deployments. Conforms to the BuildOptions interface from esbuild. You should only need to specify theexternal
option to exclude certain modules from the bundle:serverBundleOptions: { external: ['fsevents', 'sharp', 'lightningcss', 'vite'], }
Modules marked as
external
will be installed in the server directory and included in the deployment package.