Surge
Surge is a simple CLI for publishing static sites. pageflare runs locally (or in CI) after your build and before surge deploys the output.
How It Works
Section titled “How It Works”Build your site, run pageflare to optimize the output directory, then deploy with surge.
Step 1 — Install pageflare
Section titled “Step 1 — Install pageflare”npm install -D @pageflare/cliStep 2 — Configure the Build
Section titled “Step 2 — Configure the Build”Add a deploy script to your package.json:
{ "scripts": { "build": "astro build", "optimize": "npx @pageflare/cli dist/ --in-place --no-progress", "deploy": "npm run build && npm run optimize && surge dist/ my-site.surge.sh" }}Or run the commands manually:
npm run buildnpx @pageflare/cli dist/ --in-place --no-progresssurge dist/ my-site.surge.shCI/CD with GitHub Actions
Section titled “CI/CD with GitHub Actions”name: Deploy to Surge
on: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Build site run: npm ci && npm run build
- name: Optimize with pageflare uses: getappz/pageflare-cli@v1 with: args: "dist/ --in-place"
- name: Deploy to Surge run: npx surge dist/ my-site.surge.sh --token ${{ secrets.SURGE_TOKEN }}Step 3 — Pro License
Section titled “Step 3 — Pro License”Set PAGEFLARE_LICENSE as an environment variable locally or as a CI secret:
export PAGEFLARE_LICENSE=your-license-keyStep 4 — Verify
Section titled “Step 4 — Verify”After running pageflare, check the terminal output:
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 |
|---|---|
| Astro | dist/ |
| Next.js static export | out/ |
| Hugo | public/ |
| Vite | dist/ |
| Eleventy | _site/ |
Troubleshooting
Section titled “Troubleshooting”Surge deploys unoptimized files
Make sure pageflare runs before surge. The --in-place flag overwrites the files in the output directory so Surge deploys the optimized versions.