Deploy Vite to Forgejo Pages

Vite sites usually need only dependency install, build, artifact sanity check, and Pages publish.

Pages

What this solves

You want a Vite app deployed from Forgejo without adding a separate hosting control plane.

Best fit

  • Static apps
  • Docs portals
  • Small product sites

How to think about it

Vite deployments are simple when the base path and output directory are explicit. Build once in Actions, verify the generated assets exist, then let Pages serve the static output.

Vite build job

name: pages
on: [push]

jobs:
  build:
    runs-on: docker
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - run: npm run build
      - run: test -f dist/index.html

Practical path

  1. 01 Run the Vite build in an Actions workflow.
  2. 02 Check that the output directory and base path match the deployment URL.
  3. 03 Publish to Pages and add a domain after the first successful deploy.

When to choose another path

Check `base` in Vite config when serving from a path.

Make environment variables explicit for production builds.

Use previews before replacing an existing public site.

Next resources

Related reading