AWS via SST
SST (Serverless Stack) is an infrastructure-as-code framework for deploying to AWS. For static sites using SST’s StaticSite construct, pageflare integrates as part of the build command.
How It Works
Section titled “How It Works”SST’s StaticSite construct runs a build command and deploys the output to S3 + CloudFront. Add pageflare to the build command so the optimized files are what gets deployed.
Step 1 — Install pageflare
Section titled “Step 1 — Install pageflare”npm install -D @pageflare/cliStep 2 — Configure SST
Section titled “Step 2 — Configure SST”Update the build command in your sst.config.ts:
new StaticSite(stack, "Site", { path: ".", buildCommand: "npm run build && npx @pageflare/cli dist/ --in-place --no-progress", buildOutput: "dist",});Or add pageflare to your package.json build script:
{ "scripts": { "build": "astro build && npx @pageflare/cli dist/ --in-place --no-progress" }}Step 3 — Pro License
Section titled “Step 3 — Pro License”Set the environment variable in your .env file or pass it during deployment:
PAGEFLARE_LICENSE=your-license-key npx sst deployOr add it to the SST environment:
new StaticSite(stack, "Site", { environment: { PAGEFLARE_LICENSE: process.env.PAGEFLARE_LICENSE, }, buildCommand: "npm run build && npx @pageflare/cli dist/ --in-place --no-progress", buildOutput: "dist",});Step 4 — Verify
Section titled “Step 4 — Verify”After deploying, check the SST CLI output for the pageflare summary:
Done 145.2 KB saved (38.1%) 1.2s Files 42 total, 38 optimized, 4 unchanged, 0 errorsFramework Output Directories
Section titled “Framework Output Directories”| Framework | Output directory | SST buildOutput |
|---|---|---|
| Astro | dist/ | dist |
| Next.js static export | out/ | out |
| Hugo | public/ | public |
| Vite | dist/ | dist |
Troubleshooting
Section titled “Troubleshooting”Build command not running
Make sure the buildCommand is set in the StaticSite construct, not just in package.json. SST uses its own build command by default.
pageflare processes 0 files
The path in the build command doesn’t match buildOutput. Both should point to the same directory.