Service for building websites using Vite.
From the command line run:
npm install @saws/website
Then add the included service, WebsiteService
to your saws.js
file.
In development, a WebsiteService
will use the Vite dev server to build and serve your website. It will also write any of your dependant service's environment variables to a .env
file for Vite to read and inject into your build.
For new WebsiteService
s that have just been added to your saws.js
file. SAWS will create a hello world world website for you.
When you deploy a WebsiteService
, a number of resources will be stood up and configured for you:
- An S3 bucket will be created that is configured to be used as a website.
- A Cloudfront distribution that serves content out of the above S3 bucket.
- A Route 53 Record Set Group to point your domain at the above Cloudfront distribution.
@saws/website
includes the WebsiteService
You can require the WebsiteService
and use it in your saws.js
file like so:
const { WebsiteService } = require('@saws/website/website-service')
const website = new WebsiteService({
name: 'my-website'
})
module.exports = website
The WebsiteService
constructor accepts the following options:
The name of your service. This should be unique across all of your services.
An array of all of the other services this service depends on. This will ensure that permissions, environment variables, and execution order are all set up.
The port to run the Vite dev server on. If the provided port is in use, a different port will automatically be chosen.
Used if you would like the service to point at a different directory for your WebsiteService
other than it's name.
A domain name that you would like to use for your website. You must own this domain and have it configured in Route 53.
Additional environment variables to include in your Vite build.
The AWS Arn to the certificate you'd like to use for your website to enable HTTPs.
When a WebsiteService
is used as a dependency, it does not attach any environment variables to the dependant services.
@saws/website
does not include any libraries with it.