Advanced25-30 minDeploymentLesson 6

Deployment module

Building and Deploying a Vite Website

Understand Vite source files, production builds, dist output, build commands, publish directories, environment variables, and routing concerns.

Learning Objectives

By the end of this lesson, you'll be able to:

  • Explain Vite source files versus production output
  • Run npm run dev and npm run build for the right purpose
  • Identify dist, build commands and publish directories
  • Read build logs and spot common Vite deployment mistakes

Why This Matters:

Vite makes development fast, but deployment should serve production output rather than the development workshop.

Before You Start:

You should be familiar with:

The Vite Deployment Flow

src/
  -> npm run build
  -> dist/
  -> Hosting platform

npm run dev starts a development server. It is for local work. npm run build creates production-ready files. In many Vite projects, the output folder is dist.

Think of the source project as the workshop and dist as the packed result. The workshop contains source files, dependencies, configuration and development conveniences. Visitors do not need that whole workshop. They need the built HTML, CSS, JavaScript and assets that Vite prepares for production.

npm run dev    # local development server
npm run build  # production output
npm run preview # local preview of the built output, when configured

Build and Deploy a Vite Site

Run the development version

Run the project locally, often with npm run dev, and fix visible local problems first.

Create the production build

Run npm run build. In many Vite projects, including GraphitEdge, the production output is dist/.

Inspect the output

Use the project preview command where configured, or inspect the generated folder so you know which files will be published.

Deploy and read the logs

For manual static hosting, deploy the built output. For Git-connected hosting, check the build command, output directory and build log.

You're on track if you can:

  • The development site runs locally
  • The production build completes
  • The output folder is identified
  • Build logs are checked
  • The live site is tested after deployment

Manual Static Hosting With Vite

When manually deploying a Vite project to static hosting, students should usually deploy the generated dist output, not the source project folder. Check whether the host expects the folder itself or the contents of the folder.

If your built files live in dist/, manually uploading the repository root can publish the wrong thing. The host may receive src/, package.json and configuration files but no production-ready homepage. Build first, inspect the output, then upload the output expected by the host.

Git-Connected Vite Deployment

A Git-connected platform normally:

  1. clones the repository
  2. installs dependencies
  3. runs the build command
  4. publishes the configured output directory

For a typical Vite project the build command is often npm run build and the publish directory is often dist. Do not type those from memory if the project differs: read package.json and the hosting platform's framework settings. If the build fails, the log is not decoration. It is the first witness.

Static Hosts for Vite and Frontend Builds

PlatformUseful forStudent note
GitHub PagesSimple repository-backed static sitesOfficial GitHub Pages guidance describes sites hosted directly from a repository: edit, push and changes go live.
NetlifyStatic sites, frontend builds, previews and Git deploymentsOfficial pricing currently includes a free tier with custom domains, SSL, deploy previews and usage credits. Check current credit limits before using it for client work.
VercelFrontend apps, Vite projects, previews and modern framework deploymentOfficial pricing separates personal/hobby and paid/team use. Check whether the project is personal, commercial, or client work before choosing a plan.
Cloudflare PagesStatic sites and frontend builds on Cloudflare infrastructureOfficial Pages documentation positions it as a Git-connected static and frontend hosting platform. Check build limits, functions support and domain setup details.

Common Vite Deployment Mistakes

  • publishing src
  • publishing the repository root when the host expects built output
  • using the wrong build command
  • setting the wrong output directory
  • missing environment variables
  • incorrect base path configuration
  • broken SPA routing or missing fallback configuration

If the site appears as a white page after deployment, open the browser console and Network panel. Missing JavaScript files, 404s for assets, or errors mentioning environment variables often point directly to the deployment setting that needs attention.

Vite Deployment Knowledge Check

Before moving forward, can you answer these?

  1. What folder do students usually deploy for a manual Vite static deployment?
  2. What does a Git-connected platform normally do after a push?
  3. Where should students look first when a Vite deployment fails?
Check Your Answers
  1. The production output folder, commonly dist, rather than the source project folder.
  2. Clone the repository, install dependencies, run the build command and publish the configured output directory.
  3. The build log, browser console and Network panel.

How confident are you with this concept?

Still confused | Getting there | Got it | Could explain it to a friend

Ready for the Next Deployment Step

Key Takeaways:

  • Deployment is a publishing workflow, not just a button.
  • The live URL is where deployment evidence is gathered.
  • The right hosting path depends on files, update workflow, support needs and ownership.
  • Troubleshooting starts with the first meaningful error.

Learning Objectives Review:

Look back at what you set out to learn. Can you now:

  • Understand Vite source files, production builds, dist output, build commands, publish directories, environment variables, and routing concerns. Check!

If you can name which part of the system you are changing, test the live result and record the outcome, deployment is becoming a repeatable workflow.

Think & Reflect:

Deployment evidence

  • What would prove this site works for someone else?

Next action

  • What should be recorded so this deployment can be repeated later?

Looking Ahead:

Next: continue with Domains, DNS, HTTPS and Going Live.

Recommended Next Steps

Continue Learning

Ready to move forward? Continue with the next tutorial in this series:

Domains, DNS, HTTPS and Going Live

Progress tracking is disabled. Enable it in to track your completed tutorials.