Vite Tutorial to Create a Vue.js 2 Project or Downgrade from Vue.js 3 to Vue.js 2 Project Full Tutorial

 

To create a Vue 2 project using Vite, you need to specify the @vitejs/plugin-vue2 plugin. Unfortunately, Vite doesn’t offer a direct preset for Vue 2 as it does for Vue 3, but you can set it up manually. Here’s how you can do it:

 

  1. Create a Vite project: Run the following command to initialize a new Vite project:

 

 

 

  • Select “Vanilla” as the template: When prompted to select a framework, choose Vanilla.

 

  • Install dependencies for Vue 2: Navigate to the project directory and install Vue 2 and the Vue 2 plugin:

 

 

Update vite.config.js: Modify your vite.config.js file to include the Vue 2 plugin:

 

 

Update the main entry point: Create or update your main.js file to initialize a Vue 2 application:

 

 

Set up your index.html: Ensure your index.html has a root element for mounting the app:

 

Run the development server: Start the development server with:

 

npm run dev

 

 

GITHUB REPO

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *