feat(aws/static-site): support `routes` arg
Refactored to use Router under-the-hood :D, tested locally with working dev, HMR, deploy.
Resolves #311
Tested used without routes arg. (like current) Tested with routes from APIGatewayV2, Function
Example snippet of the routes usage:
const backend = new sst.aws.Function('Backend', {
url: true,
handler: 'apps/backend/src/index.handler',
})
const staticSiteDistribution = new sst.aws.StaticSite('StaticFullstack', {
build: {
command: 'pnpm run build --filter="frontend"',
output: 'apps/frontend/.output/public',
},
routes: {
'/api/*': backend.url,
},
})
This deploys my starter-fullstack template to Cloudfront, with the static frontend and Hono backend served on the same domain, with working Live development access from Cloudfront's url.
Note: this update if merged as-is will remove and re-create the distribution for existing deploys.
Love it when someone already has a PR for something i wanted to add. +1
@NamesMT refactoring to use Router will cause the distribution to be removed and recreated.
That said, we have plans to attach a site to a router, and you can add additional routes.
But for now, we are moving sst/ion -> sst/sst and unfortunately this is going to be a messy process because of github's limitations
i'm going to close this PR for now and it can be re-opened in the new sst/sst repo that will be ready in the next few days if still relevant