CLI Configuration and Plugins
Configure the CLI and add plugins to extend your project.
CLI Configuration and Plugins is a free Vue Academy lesson on CoddyKit — lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Vue Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Configuring Your Build
Both Vue CLI and Vite let you customize the build through a config file.
- Vue CLI uses vue.config.js
- Vite uses vite.config.js
Here you add plugins, set aliases, configure the dev server, and more.
vite.config.js Basics
A typical vite.config.js imports the Vue plugin and exports a config object.
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
export default defineConfig({
plugins: [vue()],
server: {
port: 3000
}
})vue.config.js Basics
For Vue CLI projects, vue.config.js exports configuration the same way.
const { defineConfig } = require("@vue/cli-service")
module.exports = defineConfig({
devServer: {
port: 8080
}
})Adding Plugins
Plugins extend the build with new capabilities.
- Install with npm
- Import in the config file
- Add to the plugins array
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import vueJsx from "@vitejs/plugin-vue-jsx"
export default defineConfig({
plugins: [vue(), vueJsx()]
})Environment Variables
Store configuration that changes between environments in .env files.
- .env loaded everywhere
- .env.development for dev only
- .env.production for production builds
Defining Env Variables
In Vite, variables must be prefixed with VITE_ to be exposed to your client code.
# .env file
VITE_API_URL=https://api.example.com
VITE_APP_TITLE=My AppReading Env Variables
Access exposed variables through import.meta.env in Vite.
const apiUrl = import.meta.env.VITE_API_URL
console.log(apiUrl)
// https://api.example.comSecurity Note on Env Vars
Anything exposed to client code is visible in the browser.
- Never put secrets like private API keys in VITE_ variables
- Only public, non-sensitive config belongs here
- Keep real secrets on the server
Path Aliases
An alias shortens import paths. The common one maps @ to the src folder.
This avoids fragile relative paths like ../../components.
import { fileURLToPath, URL } from "node:url"
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
}
})Using the Alias
Once configured, import from @/ instead of relative paths.
// Without alias
import Button from "../../components/Button.vue"
// With @ alias
import Button from "@/components/Button.vue"Dev Server Options
The config file also tunes the dev server:
- port which port to listen on
- open auto-open the browser
- proxy forward API requests to avoid CORS
export default defineConfig({
server: {
port: 3000,
open: true,
proxy: {
"/api": "http://localhost:8000"
}
}
})Quick Check
Test your understanding of Vite configuration.
Recap: Configuration and Plugins
You learned to configure a Vue project:
- vite.config.js or vue.config.js hold settings
- Add plugins to the plugins array
- Use .env files with the VITE_ prefix
- Read them via import.meta.env
- Set the @ alias for clean imports
Next: template syntax and data binding.
Frequently asked questions
Is the “CLI Configuration and Plugins” lesson free?
Yes — the full text of “CLI Configuration and Plugins” is free to read here on the web, and the Vue Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Vue Academy course, upgrade to CoddyKit PRO.
What will I learn in “CLI Configuration and Plugins”?
Configure the CLI and add plugins to extend your project. You practise Vue Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Vue Academy?
No prior experience is required. Vue Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “CLI Configuration and Plugins” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Vue Academy lesson?
Yes. Every Vue Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Vue CLI Installation
- Generated Project Structure
- CLI Configuration and Plugins