Vue Build & Tooling
Estimated reading: 4 minutes 26 views

🧱 Vue CLI & Project Structure – Set Up Modern Vue Apps the Right Way (2025 Guide)


🧲 Introduction – Why Use Vue CLI?

Vue CLI (Command Line Interface) is a powerful tool that helps developers quickly scaffold, develop, and maintain Vue.js applications. It sets up the project with sensible defaults, integrates build tools like Webpack or Vite, and offers features like hot-reloading, linting, unit testing, and more.

🎯 In this guide, you’ll learn:

  • How to install and use Vue CLI
  • The standard folder structure of a Vue CLI project
  • What each file and folder is used for
  • Tips for managing and scaling Vue projects

βš™οΈ How to Install Vue CLI

To install globally:

npm install -g @vue/cli

Then check the version:

vue --version

βœ… If installed correctly, it shows the CLI version (e.g., @vue/cli 5.x.x).


πŸš€ Creating a New Vue Project

Run the following command:

vue create my-vue-app

You’ll be prompted to:

  • Pick a preset (default or Manually select features)
  • Choose Vue 2 or Vue 3
  • Select features (Babel, TypeScript, Vuex, Router, Linter, Unit Testing, etc.)

Example:

Vue CLI v5.0.0
? Please pick a preset: Manually select features
> Babel, Router, Vuex, Linter

🧱 Vue CLI Project Structure – Folder Overview

After running vue create, you’ll see a structure like this:

my-vue-app/
β”œβ”€β”€ node_modules/
β”œβ”€β”€ public/
β”‚   └── index.html
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ App.vue
β”‚   β”œβ”€β”€ main.js
β”œβ”€β”€ .gitignore
β”œβ”€β”€ babel.config.js
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ vue.config.js

πŸ“ /public/

  • Contains index.html
  • Not processed by Webpack
  • Static assets go here

πŸ“ /src/

The source code for your app:

Folder/FilePurpose
main.jsEntry point; mounts Vue app to DOM
App.vueRoot component
/components/Reusable Vue components
/views/Page-level components (used with Vue Router)
/assets/Static images, fonts, stylesheets

🧬 Detailed Breakdown of Important Files

βœ… main.js

import { createApp } from 'vue';
import App from './App.vue';

createApp(App).mount('#app');

🧠 This initializes the Vue app and mounts it to the div#app in index.html.


βœ… App.vue

<template>
  <router-view></router-view>
</template>

<script>
export default {
  name: 'App'
};
</script>

🧠 Acts as the root component for the entire app.


βœ… vue.config.js

Optional file to configure things like:

  • Dev server port
  • Aliases
  • Build options
module.exports = {
  publicPath: '/',
  lintOnSave: true
};

πŸ› οΈ CLI Tools and Features

FeatureDescription
Hot Module ReloadLive preview while editing code
ESLintAutomatically checks code style
BabelTranspiles modern JS to be browser compatible
Vue RouterAdds SPA routing with views
VuexManages global state
Unit TestingAdds Jest or Mocha test setup

🧰 CLI UI Tool

Run:

vue ui

πŸ” Launches a local GUI to create/manage projects visually.


πŸ”„ Running & Building the App

CommandPurpose
npm run serveStart dev server (usually at localhost:8080)
npm run buildBuild for production
npm run lintLint your code
npm run test:unitRun unit tests (if enabled)

πŸ“Œ Summary – Recap & Next Steps

Vue CLI helps streamline app setup and development with boilerplate-free scaffolding and a powerful configuration system. It’s perfect for both small projects and large enterprise-grade Vue applications.

πŸ” Key Takeaways:

  • Install with npm install -g @vue/cli
  • Scaffold apps using vue create
  • Follow the folder structure: src/, public/, components/
  • Use vue.config.js for custom configurations

βš™οΈ Real-World Relevance:
Used in enterprise SPA development, frontend apps, admin dashboards, eCommerce stores, and mobile PWA projects.


❓ FAQ Section

❓ What is the difference between public/ and src/?

βœ… public/ holds static files served as-is. src/ is where your Vue code lives and is processed by Webpack.


❓ Can I modify the build process in Vue CLI?

βœ… Yes, using vue.config.js to extend or override Webpack configuration.


❓ What’s the default build tool in Vue CLI?

βœ… Vue CLI 5+ uses Webpack by default but supports Vite through plugins.


❓ How do I add TypeScript or Vuex to an existing project?

βœ… Run:

vue add typescript
vue add vuex

❓ Is Vue CLI still relevant with Vite?

βœ… Yes. Vue CLI is stable and feature-rich. Vite is faster for dev builds but Vue CLI still suits complex setups.


Share Now :

Leave a Reply

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

Share

Vue CLI & Project Structure

Or Copy Link

CONTENTS
Scroll to Top