Table of Contents
Step-by-step Guide to Deploying Vue.js Apps with Vite and Netlify
Deploying a Vue.js application can be straightforward when using Vite for development and Netlify for hosting. This guide walks you through each step to get your Vue.js app live on the web.
Prerequisites
- Node.js and npm installed on your computer
- Basic knowledge of Vue.js and Vite
- A GitHub account for version control
- A Netlify account for deployment
Step 1: Create a Vue.js Project with Vite
Open your terminal and run the following commands to create a new Vue.js project using Vite:
npm create vite@latest my-vue-app -- --template vue
cd my-vue-app
npm install
Step 2: Run and Test Your App Locally
Start the development server to ensure everything works:
npm run dev
Open http://localhost:3000 in your browser to see your Vue.js app in action.
Step 3: Build the Production Version
When you’re ready to deploy, build the production files:
npm run build
This command creates a dist folder containing static files ready for deployment.
Step 4: Push Your Code to GitHub
If you haven’t already, initialize a Git repository, commit your code, and push it to GitHub:
git init
git add .
git commit -m "Initial Vue.js app with Vite"
git branch -M main
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
Step 5: Connect Your Repository to Netlify
Log in to your Netlify account and click on “New site from Git”. Choose GitHub and authorize Netlify if needed. Select your repository and configure the build settings:
- Branch to deploy: main
- Build command: npm run build
- Publish directory: dist
Step 6: Deploy Your Site
Click “Deploy site” and wait for Netlify to build and deploy your Vue.js app. Once completed, your site will be live on a Netlify URL.
Additional Tips
- Configure custom domains in Netlify settings for a professional URL.
- Set environment variables if your app requires them.
- Use Netlify’s continuous deployment to automatically update your site on code changes.
With these steps, you can efficiently deploy your Vue.js applications using Vite and Netlify, ensuring a smooth development-to-deployment workflow.