Production Deployment
Deploy your Vue app to static hosts like Netlify, Vercel, or GitHub Pages. Build your app and upload the dist/ folder.
Proper production deployment ensures your app is fast, secure, and reliable. Here are some best practices:
-
Build for production
Run the build command to generate optimized static files in thedist/directory.Terminal window npm run build -
Choose a hosting provider
- Netlify: Drag and drop your
dist/folder or connect your repository for automatic deployments. - Vercel: Import your project and set the output directory to
dist/. - GitHub Pages: Push the contents of
dist/to thegh-pagesbranch.
- Netlify: Drag and drop your
-
Configure your server
For single-page applications, ensure all routes serveindex.html. For example, in Netlify, add a_redirectsfile:/* /index.html 200 -
Set environment variables
Use.env.productionfor production-specific settings. -
Enable HTTPS
Use HTTPS for security. Most modern hosts provide free SSL certificates. -
Optimize assets
- Compress images and static files.
- Use a CDN for faster asset delivery.
Example
Section titled “Example”npm run build# then deploy dist/ to your host