CHAPTER 29
Beginner
Deploying Vue Applications
Updated: May 18, 2026
5 min read
# CHAPTER 29
Deploying Vue Applications
1. Chapter Introduction
Building a Vue app is half the work — deploying it so the world can access it completes the journey. Vite makes production builds optimized by default. Modern platforms like Vercel and Netlify deploy in minutes from GitHub.2. Learning Objectives
- Build Vue apps for production with Vite.
- Configure environment variables per environment.
- Deploy to Vercel, Netlify, and GitHub Pages.
- Configure server redirects for Vue Router history mode.
- Analyze and optimize bundle size.
3. Production Build
bash
text
vite.config.js
4. Environment Variables
bash
javascript
5. Deploy to Vercel
bash
vercel.json
6. Deploy to Netlify
bash
netlify.toml
7. Deploy to GitHub Pages
bash
vite.config.js
package.json
bash
8. Server Configuration for History Mode
nginx
apache
9. Common Mistakes
-
Not configuring server redirects: Vue Router history mode requires ALL unknown URLs to return
index.html. Without this, refreshing any page other than/gives a 404.
-
Committing
.env.localto git: This file contains secrets. Add.env.localto.gitignore.
10. MCQs
Question 1
Vite production build output is in?
Question 2
Environment variables in Vite must start with?
Question 3
Why do deployed Vue SPAs need server redirect?
Question 4
import.meta.env.PROD is?
Question 5
.env.local should be?
Question 6
Vercel auto-detects Vue/Vite project because?
Question 7
manualChunks in Vite config?
Question 8
base: '/repo-name/' in vite.config.js is needed for?
Question 9
npm run preview does?
Question 10
netlify.toml configures?
11. Interview Questions
- Q: Why do Vue Router history-mode apps need server configuration?
- Q: How do environment variables work in a Vite-based Vue project?
12. Summary
Deploying Vue with Vite is streamlined —npm run build generates an optimized /dist folder. Vercel and Netlify deploy in minutes from GitHub with zero config. The critical server-side redirect rule /* → index.html is essential for Vue Router history mode to work correctly in production.