Skip to content
cccskills
FreePublished on GitHubEnglish overview

vite

Set up and refine web projects with Vite, a tool for running development servers and building production files. It covers framework integration, environment settings, live code updates, testing configuration, and splitting code to improve loading.

OriginalShow the original description

Expert guidance for Vite development with modern build tooling, HMR, framework integrations, and performance optimization

AI rating90/ 100See how to install

Good for

  • Setting up React, Vue, or Svelte projects
  • Configuring environment variables and API proxies
  • Splitting production code into smaller files
  • Configuring Vitest tests and library builds

Overview

What it does

This skill helps configure web app development with Vite and adjust builds that generate production files. It covers React, Vue, and Svelte integration, environment variables, file path aliases, and handling images and CSS. It also supports HMR, which reflects code changes on screen, along with code splitting, custom plugins, test configuration with Vitest, and output for libraries.

When it helps

Use it when setting up a new development environment or reviewing an existing configuration to customize only what you need. It also helps adjust startup and loading performance while accounting for differences between development and production behavior.

Example requests

  • “Set up vite.config.ts and environment variable type definitions for React.”
  • “Configure a proxy from the development server to the backend API.”
  • “Review production code splitting and the Vitest configuration.”

Notes

This skill is for JavaScript and TypeScript projects that use Vite. Framework integration plugins and packages needed for CSS preprocessors such as Sass must be provided separately. The test configuration examples use Vitest.

This overview was written by AI (OpenAI Codex) from the public SKILL.md. Check the original below for the exact behavior.

Objective evaluation

AI rated this skill on four points using only the contents of its SKILL.md. Stars and popularity are not taken into account.

Clear instructionsIs it clear when to use it and what it does?
AGoodThe document explicitly covers development configuration, HMR, framework integration, and build adjustments.
Concrete stepsAre steps, inputs, outputs, and examples spelled out?
AGoodCode examples cover vite.config.ts, environment variable types, code splitting, and test configuration.
SafetyAre sending data, deleting files, and running commands disclosed?
AGoodThe material mainly provides configuration examples and does not instruct deletion, credential reading, or external data transmission.
Easy setupDoes it need few tools or API keys, and are they documented?
BPartly lackingIntegration plugins and a Sass installation example are provided, but Vite installation instructions are absent.

The total counts each point as A = 25, B = 15, C = 5. Rated by AI (OpenAI Codex) as of Oct 21, 2026. Treat it as a guide and read the original before installing.

Disagree? Request a re-evaluation

Tell us which point is wrong and why. No login needed. We will check it against the SKILL.md, redo the evaluation, and show the result here.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

Files included (1)

  • SKILL.md6.6 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Vite Development

You are an expert in Vite, modern JavaScript/TypeScript build tooling, and frontend development.

Key Principles

  • Leverage native ES modules for fast development
  • Use Vite's opinionated defaults when possible
  • Configure only what needs customization
  • Understand the dev/build differences
  • Optimize for both development speed and production performance

Project Setup

Basic Configuration

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

export default defineConfig({
  plugins: [react()],
  server: {
    port: 3000,
    open: true,
  },
  build: {
    outDir: 'dist',
    sourcemap: true,
  },
});

Path Aliases

import { defineConfig } from 'vite';

export default defineConfig({
  resolve: {
    alias: {
      '@': new URL('./src', import.meta.url).pathname,
      '@components': new URL('./src/components', import.meta.url).pathname,
      '@utils': new URL('./src/utils', import.meta.url).pathname,
    },
  },
});

Environment Variables

Usage

// .env
VITE_API_URL=https://api.example.com
VITE_APP_TITLE=My App

// In code
const apiUrl = import.meta.env.VITE_API_URL;
const isDev = import.meta.env.DEV;
const isProd = import.meta.env.PROD;
const mode = import.meta.env.MODE;

Type Definitions

// src/vite-env.d.ts
/// <reference types="vite/client" />

interface ImportMetaEnv {
  readonly VITE_API_URL: string;
  readonly VITE_APP_TITLE: string;
}

interface ImportMeta {
  readonly env: ImportMetaEnv;
}

Hot Module Replacement

Manual HMR

// For libraries without HMR support
if (import.meta.hot) {
  import.meta.hot.accept('./module.ts', (newModule) => {
    // Handle the updated module
    console.log('Module updated:', newModule);
  });

  import.meta.hot.dispose(() => {
    // Cleanup before module is replaced
  });
}

Asset Handling

Static Assets

// Import as URL
import imageUrl from './image.png';
// <img src={imageUrl} />

// Import as string (raw)
import shaderCode from './shader.glsl?raw';

// Import as worker
import Worker from './worker.ts?worker';
const worker = new Worker();

Public Directory

public/
├── favicon.ico      # Served at /favicon.ico
├── robots.txt       # Served at /robots.txt
└── images/          # Served at /images/

Framework Integrations

React

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react({
      // Babel plugins
      babel: {
        plugins: ['@emotion/babel-plugin'],
      },
    }),
  ],
});

Vue

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [vue()],
});

Svelte

import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';

export default defineConfig({
  plugins: [svelte()],
});

Build Optimization

Code Splitting

// Dynamic imports create separate chunks
const AdminPanel = lazy(() => import('./AdminPanel'));

// Manual chunks
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['react', 'react-dom'],
          utils: ['lodash', 'date-fns'],
        },
      },
    },
  },
});

Chunk Size Optimization

export default defineConfig({
  build: {
    chunkSizeWarningLimit: 500,
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return id.split('node_modules/')[1].split('/')[0];
          }
        },
      },
    },
  },
});

CSS Handling

CSS Modules

// styles.module.css is auto-detected
import styles from './styles.module.css';

// <div className={styles.container}>

PostCSS

// postcss.config.js
export default {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

Preprocessors

// Automatically handled with package installed
// npm install -D sass
import './styles.scss';

Proxy Configuration

export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:4000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/socket.io': {
        target: 'ws://localhost:4000',
        ws: true,
      },
    },
  },
});

Plugin Development

// my-vite-plugin.ts
import type { Plugin } from 'vite';

export function myPlugin(): Plugin {
  return {
    name: 'my-plugin',

    // Hook: modify config
    config(config, { mode }) {
      return {
        define: {
          __BUILD_TIME__: JSON.stringify(new Date().toISOString()),
        },
      };
    },

    // Hook: transform code
    transform(code, id) {
      if (id.endsWith('.md')) {
        return {
          code: `export default ${JSON.stringify(code)}`,
          map: null,
        };
      }
    },

    // Hook: configure dev server
    configureServer(server) {
      server.middlewares.use((req, res, next) => {
        // Custom middleware
        next();
      });
    },
  };
}

Testing with Vitest

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'jsdom',
    setupFiles: './src/test/setup.ts',
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
    },
  },
});

SSR Configuration

export default defineConfig({
  build: {
    ssr: true,
    rollupOptions: {
      input: './src/entry-server.ts',
    },
  },
  ssr: {
    external: ['express'],
    noExternal: ['my-ui-library'],
  },
});

Library Mode

export default defineConfig({
  build: {
    lib: {
      entry: './src/index.ts',
      name: 'MyLib',
      fileName: (format) => `my-lib.${format}.js`,
    },
    rollupOptions: {
      external: ['react', 'react-dom'],
      output: {
        globals: {
          react: 'React',
          'react-dom': 'ReactDOM',
        },
      },
    },
  },
});

Best Practices

  • Use vite preview to test production builds locally
  • Keep dependencies that support ESM in regular deps
  • Use optimizeDeps.include for CommonJS dependencies
  • Enable build.sourcemap for debugging production
  • Use server.warmup for faster dev server starts

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

fastapi-python

FreeSummaryAI rating 80

Build Python APIs with FastAPI using clear routes, validated inputs, and consistent error handling. It guides asynchronous database and API calls, reusable dependencies, caching, and code organization to support readable implementations and responsive services.

  • Designing API routes and input validation
  • Reviewing asynchronous database and API calls
  • Organizing error handling and logging
debpalash/VoiceStudio79KUpdated Oct 20, 2026

voicestudio

FreeSummaryAI rating 100

Connect agents and automated workflows to VoiceStudio to generate speech with saved or designed voices, transcribe recordings, create subtitles, and manage dubbing or narration. It uses the running backend and checks available models and capabilities.

  • Generating narration with a saved voice
  • Transcribing recordings and creating subtitles
  • Managing dubbing while preserving timing and background audio
debpalash/VoiceStudio79KUpdated Oct 20, 2026

voicestudio-maintainer

FreeSummaryAI rating 100

Maintain VoiceStudio by investigating reported bugs, reviewing contributed changes, diagnosing automated check failures, and preparing requested releases. It guides focused fixes, testing, and packaging verification for the Electron app and Python backend.

  • Investigating reported VoiceStudio bugs
  • Reviewing contributor pull requests
  • Diagnosing automated check failures
debpalash/VoiceStudio79KUpdated Oct 20, 2026

See all skills by debpalash

Report a problem with this skill