Vite Configuration and Patterns

VerifiedSafe

Provides Vite configuration patterns including import aliases (@), build chunking, environment variables, and asset imports. Useful when setting up a Vite project, simplifying imports, or troubleshooting build issues.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurf
#vite#build-tool#configuration#aliases#env-variables

Recommended for

Automated summary

Configures Vite build tool with import aliases, proxy, and optimized build chunks.

Strengths

  • Simplifies imports using @ alias
  • Provides proxy configuration for development
  • Enables manual chunk splitting for vendor libraries
  • Handles environment variables with VITE_ prefix

Limitations

  • Requires both vite.config.ts and tsconfig.json alias settings
  • Environment variables must be prefixed with VITE_
  • May require webpack knowledge for migration
When to use it

When setting up a new Vite project or configuring an existing one for efficient development and builds.

When not to use it

When using a different build tool (Webpack, Parcel) or for simple static sites without complex configuration.

Security analysis

Safe
Quality score85/100

The skill provides Vite configuration guidance with no destructive commands, obfuscated code, or data exfiltration. The listed Bash commands are standard development commands and pose no risk.

No concerns found

How this analysis is made

Examples

Set up import alias
Configure Vite with @ alias pointing to ./src in both vite.config.ts and tsconfig.json.
Add development proxy
Set up a Vite proxy to forward /api requests to http://localhost:3000.
Optimize bundle chunks
Configure Vite build to split vendor libraries (react, react-dom, react-router-dom, @tanstack/react-query, recharts) into separate chunks.

name: vite description: > Vite build tool patterns and configuration. Trigger: When configuring Vite, setting up aliases, or resolving build issues. license: MIT metadata: author: migestion version: '1.0' scope: [web] auto_invoke: 'Working with Vite configuration' allowed-tools: Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task

Import Aliases (REQUIRED)

// vite.config.ts
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
});

// tsconfig.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Usage

// ✅ ALWAYS: Use @ alias
import { Button } from '@/components/ui/Button';
import { useClientsStore } from '@/stores/clients.store';

// ❌ NEVER: Relative imports
import { Button } from '../../../components/ui/Button';

Configuration

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
    },
  },
  build: {
    outDir: 'dist',
    sourcemap: true,
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['react', 'react-dom'],
          vendor-router: ['react-router-dom'],
          vendor-query: ['@tanstack/react-query'],
          vendor-charts: ['recharts'],
        },
      },
    },
  },
});

Environment Variables

// ✅ Client-side variables (VITE_ prefix)
const apiUrl = import.meta.env.VITE_API_URL;

// ✅ With fallback
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:3000';

// ✅ Type-safe
interface ImportMetaEnv {
  readonly VITE_API_URL: string;
  readonly VITE_SOCKET_URL: string;
}

interface ImportMeta {
  readonly env: ImportMetaEnv;
}

Commands

npm run dev:web              # Start dev server (port 5173)
npm run build:web            # Build for production
npm run preview              # Preview production build

Asset Imports

// ✅ Images
import logo from '@/assets/logo.png';
<img src={logo} alt="Logo" />

// ✅ CSS
import './styles.css';

// ✅ JSON
import data from './data.json';

Related Skills

  • migestion-web - MiGestion Web patterns
  • react-18 - React component patterns

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/vite-configuration-and-patterns-mmio70tc' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/vite-configuration-and-patterns-mmio70tc/download' --output '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md.part' && mv '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md.part' '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md' && test -s '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/vite' && cp -R '.skill-downloads/vite-configuration-and-patterns-mmio70tc' '.claude/skills/vite'

Cursor
test -f '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md' && test -s '.skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/vite' && cp -R '.skill-downloads/vite-configuration-and-patterns-mmio70tc' '.cursor/skills/vite'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/vite-configuration-and-patterns-mmio70tc'

openskills read 'vite-configuration-and-patterns-mmio70tc'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/vite-configuration-and-patterns-mmio70tc/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills