Vue.js course · Module 12: Testing & Deploy
Project: Mars Mission Launch - Complete Production App
In this lesson7
The final application is ready for launch! Your code is flying to Mars!
Over five lessons you assembled the launch procedure from separate elements: component tests, logic tests, E2E, the build and deployment. Each worked in its own lesson, but a real project needs all of them at once, in one repository, tied together so that no step depends on the operator's memory. This project is a complete production configuration of the gallery - we will go through it file by file.
A launch-ready Vite configuration
The vite.config.js file starts with three plugins: vue() compiles the components, ViteImageOptimizer compresses images, and visualizer draws a bundle size report and opens it in the browser right away:
// vite.config.js - Production ready
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'
import { visualizer } from 'rollup-plugin-visualizer'
export default defineConfig({
plugins: [
vue(),
ViteImageOptimizer({
jpg: { quality: 80 },
png: { quality: 80 },
webp: { quality: 80 }
}),
visualizer({
open: true,
gzipSize: true
})
],The plugins do not touch the files in src - they work on what travels to dist. The second part of the file configures the build: the terser minifier, bundle splitting and the development server port:
// vite.config.js - continuation of defineConfig
build: {
outDir: 'dist',
sourcemap: false,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{ name: 'vue-vendor', test: /node_modules[\\/](vue|@vue|vue-router|pinia)[\\/]/ },
{ name: 'utils', test: /node_modules[\\/]@vueuse[\\/]/ }
]
}
}
}
},
server: {
port: 3000,
open: true
}
})The drop_console and drop_debugger options in terserOptions remove all console.log calls and debugger statements from the production code; the source files stay untouched. Terser has to be installed separately (npm install -D terser), and Vite 8's default minifier, Oxc, does the same with the dropConsole option in build.rolldownOptions.output.minify.compress. Splitting is described by codeSplitting: each group has a bundle name and a test, a regular expression matched against the module path, in which [\\/] catches both the slash and the backslash of Windows paths. Older configurations with rollupOptions.output.manualChunks in object form no longer work - Vite 8 aborts the build on them.
Scripts in package.json
The package.json file gathers the launch procedure commands in one place - every pipeline stage will later call one of these scripts:
// package.json
{
"name": "gallery-app",
"version": "1.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"test": "vitest",
"test:ui": "vitest --ui",
"test:coverage": "vitest --coverage",
"lint": "eslint . --ext .vue,.js,.ts",
"format": "prettier --write .",
"type-check": "vue-tsc --noEmit",
"deploy": "npm run build && vercel --prod"
}
}lint inspects the code with ESLint, format tidies it with Prettier, and type-check runs vue-tsc, that is TypeScript type checking that also covers .vue files. deploy ships the build with vercel --prod, which is equivalent to vercel deploy --prod.
Lazy loading components
A heavy component, for example a telemetry chart opened on demand, does not have to sit in the main bundle. The defineAsyncComponent function from the vue package takes a function with a dynamic import() and returns a component that is downloaded on its first render:
import { defineAsyncComponent } from 'vue'
const TelemetryChart = defineAsyncComponent(() =>
import('./components/TelemetryChart.vue')
)The build moves TelemetryChart.vue into a separate bundle, and in the template you use it like any other component. Router routes only need a plain () => import().
CI/CD pipeline
The workflow divides the work into three jobs. The first one, test, runs on every push and pull request and performs a full quality check:
# .github/workflows/ci.yml
name: CI/CD
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Type check
run: npm run type-check
- name: Run tests
run: npm run test:coverage
- name: Upload coverage
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}The order is deliberate: the cheapest checks come first. cache: 'npm' keeps the packages between runs, and the Codecov action uploads the coverage report with a token from the repository secrets. The build job waits for a green test thanks to the needs field and saves dist as an artifact:
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: distAn artifact is a file GitHub stores between jobs. Version v3 of the artifact actions stopped working on January 30, 2025, which is why old workflows fail today. The last job deploys the application only from the main branch, which the if condition checks:
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v7
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Deploy to Vercel
uses: amondnet/vercel-action@v42
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
vercel-args: '--prod'Pull requests therefore go through tests and the build without a deployment. The downloaded artifact is useful for static hosting, because Vercel by default builds the project on its side, from the uploaded code.
The Docker capsule
The container version is the Dockerfile from the previous lesson with comments and a HEALTHCHECK that checks every 30 seconds whether nginx responds:
# Dockerfile - Multi-stage build
FROM node:24-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies (the build needs devDependencies too)
RUN npm ci
# Copy source
COPY . .
# Build
RUN npm run build
# Production stage
FROM nginx:alpine
# Copy build
COPY /app/dist /usr/share/nginx/html
# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Health check
HEALTHCHECK \
CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]Watch out for a common mistake: npm ci --only=production in the build stage skips devDependencies, where Vite lives, so the build would fail. Only dist ends up in the final image anyway.
Optimized nginx
The server configuration adds gzip compression, security headers and separate cache rules:
# nginx.conf - Optimized
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip
gzip on;
gzip_vary on;
gzip_types text/plain text/css text/xml text/javascript
application/x-javascript application/xml+rss
application/javascript application/json;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
# Deprecated header: 0 disables the legacy XSS filter, use a Content-Security-Policy instead
add_header X-XSS-Protection "0" always;
# SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Don't cache index.html
location = /index.html {
add_header Cache-Control "no-cache, must-revalidate";
}
}index.html must not end up in a long cache, because it points to the current bundle names. X-XSS-Protection is deprecated and MDN recommends Content-Security-Policy instead, hence the value 0. A trap: add_header at the server level is not passed down to location blocks that have their own add_header, so the security headers must be repeated there.
Monitoring and SEO
After launch you watch the instruments: performance profiling in Vue DevTools shows components that render too often, Lighthouse audits page loading, and Web Vitals metrics (LCP, INP, CLS) reflect the experience of real users. An SPA sends search engine bots an empty index.html, and JavaScript draws the content. Google and Bing cope with simple applications, but they do not wait for data fetched asynchronously, so only SSR or SSG gives bots the full HTML, most easily with Nuxt - you will meet it at the Quantum Laboratory. Before a manual launch keep the pipeline order: lint and type checking, tests, npm run build, a preview with npm run preview, and vercel --prod at the very end.
CONGRATULATIONS! You have completed your training at the NOVA LAB Launch Platform!
Your code has passed all pre-launch tests and is ready for the Mars mission!
Your application now:
- Is fully tested (all systems checked)
- Is optimized for performance (ready for harsh space conditions)
- Is ready for deployment (launch procedure complete)
- Has a CI/CD pipeline (automatic control systems)
- Runs in a Docker container (a sealed capsule)
LAUNCH MISSION ACCOMPLISHED!
My advice: copy this set of files into your own repository and adapt it to your application - it is a skeleton for every future Vue project. Your code is launching to Mars, and three more NOVA LAB locations lie ahead of you; in the Holographic Chamber you will bring the interface to life with animations.
Remember: an application is ready for flight only when tests, build and deployment run automatically, without the operator.
Code for this lesson: App.vue
<script setup>
import { ref, computed, onMounted } from 'vue'
// NOVA LAB - Monitoring Dashboard
const metrics = ref({
uptime: 99.9,
responseTime: 145,
errorRate: 0.02,
activeUsers: 1247,
requestsPerMinute: 3542,
cpuUsage: 45,
memoryUsage: 62,
diskUsage: 38
})
const alerts = ref([
{ id: 1, level: 'warning', message: 'High memory usage detected', time: '2 min ago' },
{ id: 2, level: 'info', message: 'Deployment completed successfully', time: '15 min ago' }
])
const performanceData = ref([
{ time: '00:00', value: 120 },
{ time: '04:00', value: 95 },
{ time: '08:00', value: 180 },
{ time: '12:00', value: 220 },
{ time: '16:00', value: 195 },
{ time: '20:00', value: 150 }
])
const healthStatus = computed(() => {
const { uptime, errorRate, responseTime } = metrics.value
if (uptime >= 99.5 && errorRate < 0.1 && responseTime < 200) {
return { status: 'healthy', label: 'Healthy', color: '#00ff88' }
} else if (uptime >= 99 && errorRate < 0.5 && responseTime < 500) {
return { status: 'warning', label: 'Warning', color: '#ffa500' }
} else {
return { status: 'critical', label: 'Critical', color: '#ff0000' }
}
})
const performanceScore = computed(() => {
const avgResponseTime = metrics.value.responseTime
if (avgResponseTime < 100) return 'Excellent'
if (avgResponseTime < 200) return 'Good'
if (avgResponseTime < 500) return 'Fair'
return 'Poor'
})
function refreshMetrics() {
// Simulate metrics update
metrics.value.responseTime = Math.floor(Math.random() * 100) + 100
metrics.value.activeUsers = Math.floor(Math.random() * 500) + 1000
metrics.value.requestsPerMinute = Math.floor(Math.random() * 1000) + 3000
metrics.value.cpuUsage = Math.floor(Math.random() * 30) + 30
metrics.value.memoryUsage = Math.floor(Math.random() * 20) + 50
}
onMounted(() => {
// Auto-refresh every 5 seconds
setInterval(refreshMetrics, 5000)
})
</script>
<template>
<div class="monitoring-dashboard">
<div class="header">
<h1>Mission Control Dashboard</h1>
<p>NOVA LAB Real-Time Monitoring</p>
</div>
<div class="health-status" :style="{ borderColor: healthStatus.color }">
<div class="status-icon" :style="{ color: healthStatus.color }">
{{ healthStatus.status === 'healthy' ? 'OK' : healthStatus.status === 'warning' ? '!' : 'X' }}
</div>
<div class="status-info">
<h2>System Health: {{ healthStatus.label }}</h2>
<p>Uptime: {{ metrics.uptime }}% | Performance: {{ performanceScore }}</p>
</div>
</div>
<div class="metrics-grid">
<div class="metric-card">
<div class="metric-icon">◆</div>
<div class="metric-value">{{ metrics.activeUsers.toLocaleString() }}</div>
<div class="metric-label">Active Users</div>
</div>
<div class="metric-card">
<div class="metric-icon">↯</div>
<div class="metric-value">{{ metrics.responseTime }}ms</div>
<div class="metric-label">Avg Response Time</div>
</div>
<div class="metric-card">
<div class="metric-icon">▲</div>
<div class="metric-value">{{ metrics.requestsPerMinute.toLocaleString() }}</div>
<div class="metric-label">Requests/Min</div>
</div>
<div class="metric-card">
<div class="metric-icon">●</div>
<div class="metric-value">{{ metrics.errorRate }}%</div>
<div class="metric-label">Error Rate</div>
</div>
</div>
<div class="resource-usage">
<h3>Resource Usage</h3>
<div class="resource-bars">
<div class="resource-item">
<div class="resource-header">
<span>CPU</span>
<span>{{ metrics.cpuUsage }}%</span>
</div>
<div class="resource-bar">
<div
class="resource-fill"
:style="{
width: metrics.cpuUsage + '%',
background: metrics.cpuUsage > 80 ? '#ff0000' : metrics.cpuUsage > 60 ? '#ffa500' : '#00ff88'
}"
></div>
</div>
</div>
<div class="resource-item">
<div class="resource-header">
<span>Memory</span>
<span>{{ metrics.memoryUsage }}%</span>
</div>
<div class="resource-bar">
<div
class="resource-fill"
:style="{
width: metrics.memoryUsage + '%',
background: metrics.memoryUsage > 80 ? '#ff0000' : metrics.memoryUsage > 60 ? '#ffa500' : '#00ff88'
}"
></div>
</div>
</div>
<div class="resource-item">
<div class="resource-header">
<span>Disk</span>
<span>{{ metrics.diskUsage }}%</span>
</div>
<div class="resource-bar">
<div
class="resource-fill"
:style="{
width: metrics.diskUsage + '%',
background: metrics.diskUsage > 80 ? '#ff0000' : metrics.diskUsage > 60 ? '#ffa500' : '#00ff88'
}"
></div>
</div>
</div>
</div>
</div>
<div class="alerts-panel">
<h3>Recent Alerts</h3>
<div class="alerts-list">
<div
v-for="alert in alerts"
:key="alert.id"
class="alert-item"
:class="alert.level"
>
<span class="alert-icon">
{{ alert.level === 'warning' ? '!' : alert.level === 'error' ? 'X' : 'ℹ' }}
</span>
<span class="alert-message">{{ alert.message }}</span>
<span class="alert-time">{{ alert.time }}</span>
</div>
</div>
</div>
<div class="actions">
<button @click="refreshMetrics" class="refresh-btn">
Refresh Metrics
</button>
</div>
</div>
</template>
<style scoped>
.monitoring-dashboard {
background: #0a0e27;
color: #00ff88;
padding: 2rem;
min-height: 100vh;
font-family: 'Courier New', monospace;
}
.header {
text-align: center;
margin-bottom: 2rem;
border-bottom: 2px solid #00b4d8;
padding-bottom: 1rem;
}
.header h1 {
color: #00ff88;
text-shadow: 0 0 10px #00ff88;
margin: 0;
}
.health-status {
display: flex;
align-items: center;
gap: 1.5rem;
background: rgba(0, 180, 216, 0.1);
border: 3px solid;
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 2rem;
}
.status-icon {
font-size: 3rem;
}
.status-info h2 {
margin: 0 0 0.5rem 0;
color: #fff;
}
.status-info p {
margin: 0;
color: #00b4d8;
}
.metrics-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.metric-card {
background: rgba(0, 180, 216, 0.1);
border: 2px solid #00b4d8;
border-radius: 8px;
padding: 1.5rem;
text-align: center;
transition: transform 0.3s;
}
.metric-card:hover {
transform: translateY(-5px);
box-shadow: 0 5px 20px rgba(0, 180, 216, 0.3);
}
.metric-icon {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
.metric-value {
font-size: 2rem;
color: #00ff88;
font-weight: bold;
margin-bottom: 0.5rem;
}
.metric-label {
color: #00b4d8;
font-size: 0.9rem;
}
.resource-usage, .alerts-panel {
background: rgba(0, 180, 216, 0.1);
border: 1px solid #00b4d8;
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.resource-usage h3, .alerts-panel h3 {
color: #00b4d8;
margin-top: 0;
}
.resource-bars {
display: flex;
flex-direction: column;
gap: 1rem;
}
.resource-item {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.resource-header {
display: flex;
justify-content: space-between;
color: #fff;
font-size: 0.9rem;
}
.resource-bar {
height: 20px;
background: rgba(0, 255, 136, 0.1);
border-radius: 10px;
overflow: hidden;
border: 1px solid #00b4d8;
}
.resource-fill {
height: 100%;
transition: width 0.5s, background 0.5s;
border-radius: 10px;
}
.alerts-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.alert-item {
display: flex;
align-items: center;
gap: 1rem;
padding: 1rem;
border-radius: 8px;
border-left: 4px solid;
}
.alert-item.warning {
background: rgba(255, 165, 0, 0.1);
border-color: #ffa500;
}
.alert-item.error {
background: rgba(255, 0, 0, 0.1);
border-color: #ff0000;
}
.alert-item.info {
background: rgba(0, 180, 216, 0.1);
border-color: #00b4d8;
}
.alert-icon {
font-size: 1.5rem;
}
.alert-message {
flex: 1;
color: #fff;
}
.alert-time {
color: #00b4d8;
font-size: 0.85rem;
}
.actions {
text-align: center;
}
.refresh-btn {
padding: 1rem 2rem;
background: rgba(0, 180, 216, 0.2);
border: 2px solid #00b4d8;
color: #00b4d8;
font-size: 1rem;
font-family: 'Courier New', monospace;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s;
}
.refresh-btn:hover {
background: #00b4d8;
color: #0a0e27;
box-shadow: 0 0 20px #00b4d8;
}
</style>Docs entries used in this lesson
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. How do you implement lazy loading of a component in Vue 3?
2. What tools help monitor the performance of a Vue application?
These are 2 of 4 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Horizontal ordering
Arrange the syntax for lazy loading a component:
- Code editor
Configure a complete vite.config.js with: vue plugin, image optimizer, visualizer, build options with bundle splitting (in Vite 8 through codeSplitting instead of manualChunks).
- Vertical ordering
Arrange the production preparation steps from first to last:
- Click in order
Arrange the production deployment command for Vercel:
- Vertical ordering
Arrange the GitHub Actions CI/CD workflow steps in order:
- Click in order
Arrange the production deployment command for Netlify:
- Horizontal ordering
Arrange the nginx directive for SPA routing:
- Click in order
Arrange the Docker container run command with port mapping:
Tasks after this lesson
- QuestionLazy loading components
- Put in orderdefineAsyncComponent
- Coding taskPractice: Full production configuration
- QuestionPerformance monitoring
- Put in orderPre-deployment checklist
- Click in orderVercel CLI deployment
- QuestionSEO in Vue SPA
- QuestionTerser in Vite
- Put in orderGitHub Actions - workflow stages
- Click in orderNetlify deploy CLI
- Put in orderNginx try_files
- Click in orderDocker run
- Project to submitSubmit the final project to Mentor
- VideoModule summary