web-tooling-vite
Vite設定、パスエイリアス、ベンダーチャンク分割、環境別ビルド、Rolldownによるコード分割、Sassの最新API、ビルドターゲット、モジュールプリロードなど、Web開発の効率化とパフォーマンス向上に不可欠なツール設定を最適化するSkill。
📜 元の英語説明(参考)
Vite config, path aliases, vendor chunk splitting, environment-specific builds, Rolldown codeSplitting, Sass modern API, build targets, module preload
🇯🇵 日本人クリエイター向け解説
Vite設定、パスエイリアス、ベンダーチャンク分割、環境別ビルド、Rolldownによるコード分割、Sassの最新API、ビルドターゲット、モジュールプリロードなど、Web開発の効率化とパフォーマンス向上に不可欠なツール設定を最適化するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o web-tooling-vite.zip https://jpskill.com/download/10316.zip && unzip -o web-tooling-vite.zip && rm web-tooling-vite.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10316.zip -OutFile "$d\web-tooling-vite.zip"; Expand-Archive "$d\web-tooling-vite.zip" -DestinationPath $d -Force; ri "$d\web-tooling-vite.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
web-tooling-vite.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
web-tooling-viteフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Viteビルドツールのパターン
クイックガイド: Viteは、フロントエンドアプリケーションのためのビルドツールです。
vite.config.tsとtsconfig.jsonの間でパスエイリアスを同期させてください(またはVite 8ではresolve.tsconfigPathsを使用してください)。ベンダーチャンク分割を使用してください(Vite 7ではmanualChunks、Vite 8ではcodeSplitting.groups)。環境固有のビルドにはloadEnv()を使用してください。Vite 8はデフォルトでRolldownを使用し、build.rolldownOptionsを使用します。現在のバージョン: Vite 8(安定版、2026年3月)とRolldownバンドラー。Vite 7(2025年6月)も広く展開されています。
<critical_requirements>
重要: このスキルを使用する前に
すべてのコードはCLAUDE.mdのプロジェクト規約に従う必要があります(kebab-case、名前付きエクスポート、インポート順序、
import type、名前付き定数)
(vite.config.tsとtsconfig.jsonの間でパスエイリアスを同期させ続ける必要があります - 不一致はインポート解決の失敗を引き起こします)
(Vite 8以降ではbuild.rolldownOptionsを使用する必要があります - build.rollupOptionsは非推奨のエイリアスです)
(Vite 8ではチャンク分割にcodeSplitting.groupsを使用する必要があります - オブジェクト形式のmanualChunksは削除され、関数形式は非推奨です)
(非推奨のbuild.polyfillModulePreloadの代わりにbuild.modulePreload.polyfillを使用する必要があります)
(Sass modern APIを使用する必要があります(Vite 6以降ではデフォルト) - レガシーAPIはVite 7で削除されました)
</critical_requirements>
自動検出: Vite, vite.config.ts, vite.config.js, manualChunks, advancedChunks, codeSplitting, loadEnv, rolldownOptions, rollupOptions, modulePreload, resolve.alias, resolve.tsconfigPaths, build.target, baseline-widely-available
使用するタイミング:
- フロントエンドアプリケーションのためのViteビルドツールの設定
- tsconfigとの同期によるパスエイリアスの設定
- 本番ビルドのためのベンダーチャンク分割
- 環境固有のビルド構成(dev/staging/prod)
- Vite 7 (Rollup) から Vite 8 (Rolldown) への移行
- モジュールプリロード、ビルドターゲット、またはSassプリプロセスの設定
使用しないタイミング:
- サーバーサイドのビルドプロセス(Dockerビルド、CI/CDパイプライン)
- リンターまたはフォーマッターの設定(別のツールスキル)
- TypeScriptコンパイラオプション(別のツールスキル)
カバーする主要なパターン:
- tsconfigとの同期によるパスエイリアス(およびVite 8の
resolve.tsconfigPaths) - ベンダーチャンク分割(Vite 7では
manualChunks、Vite 8ではcodeSplitting) loadEnvとdefineによる環境固有のビルド- モジュールプリロードの設定
- Sass modern APIの設定
- 環境API(実験的、主にフレームワーク作成者向け)
- ビルドターゲットの選択 (
baseline-widely-available)
詳細なリソース:
- examples/core.md - すべてのパターンの完全なコード例
- reference.md - クイックルックアップテーブル、移行チェックリスト、外部リンク
<philosophy>
哲学
Viteは高速で、デフォルトでゼロ設定、そして環境を意識しているべきです。ビルドツールは開発中は邪魔にならず(インスタントHMR)、本番環境向けに積極的に最適化します(チャンク分割、minify、ツリーシェイキング)。
このスキルを使用するタイミング:
- Viteビルドの設定または最適化
- パスエイリアス、チャンク分割、または環境設定の設定
- Viteのメジャーバージョン間の移行(7から8)
- Sass、ビルドターゲット、またはモジュールプリロードの設定
使用しないタイミング:
- ランタイムアプリケーションコード(これはビルド時の設定のみです)
- SSRメタフレームワークの設定(メタフレームワークスキルによって処理されます)
- CI/CDパイプラインの設定
</philosophy>
<patterns>
コアパターン
パターン1: パスエイリアス
深い相対インポートを排除するために、vite.config.tsとtsconfig.jsonの両方でパスエイリアスを設定します。Vite 8では、手動のresolve.aliasの代わりにresolve.tsconfigPaths: trueを使用します。
// Vite 7: manual resolve.alias
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@components": path.resolve(__dirname, "./src/components"),
},
},
// Vite 8: built-in tsconfig path resolution
resolve: {
tsconfigPaths: true, // tsconfig.jsonから自動的に読み取ります
},
重要なポイント: resolve.tsconfigPathsはデフォルトで無効になっています(パフォーマンスコスト)。tsconfigパスを使用している場合にのみ有効にしてください。完全な設定についてはexamples/core.mdを参照してください。
パターン2: ベンダーチャンク分割
より良いキャッシュのために、ベンダーの依存関係を別々のチャンクに分割します。APIはVite 7と8で異なります。
// Vite 7: manualChunks (オブジェクト形式)
build: {
rollupOptions: {
output: {
manualChunks: {
"vendor": ["react", "react-dom"],
},
},
},
},
// Vite 8: codeSplitting.groups (正規表現ベース)
build: {
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{ name: "vendor", test: /[\\/]node_modules[\\/]react(-dom)?[\\/]/ },
],
},
},
},
},
重要なポイント: Vite 8では、オブジェクト形式のmanualChunksは削除され、関数形式は非推奨になりました。Rolldownは、コード分割されたグループとともにruntime.jsチャンクを生成します。完全な例についてはexamples/core.mdを参照してください。
パターン3: 環境固有のビルド
環境を意識した設定にはloadEnv()を使用し、ビルド時の定数にはdefineを使用します。
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
build: {
sourcemap: mode === "development",
minify: mode === "production",
},
};
});
重要なポイント: loadEnv()の3番目の引数("")は、VITE_プレフィックスが付いたものだけでなく、すべての環境変数をロードします。環境選択には--modeフラグを使用してください。スクリプトを含む完全な設定についてはexamples/core.mdを参照してください。
パターン4: モジュールプリロードの設定
build: {
modulePreload: {
polyfill: false, // 最新のターゲットのみの場合は無効にします
resolveDependencies: (filename, deps, { hostId, hostType }) => {
return deps.filter((dep) => !dep.includes("large-vendor"));
},
},
},
重要なポイント:
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Vite Build Tool Patterns
Quick Guide: Vite is the build tool for frontend apps. Keep path aliases in sync between
vite.config.tsandtsconfig.json(or useresolve.tsconfigPathsin Vite 8). Use vendor chunk splitting (manualChunksin Vite 7,codeSplitting.groupsin Vite 8). UseloadEnv()for environment-specific builds. Vite 8 uses Rolldown by default withbuild.rolldownOptions.Current versions: Vite 8 (stable, March 2026) with Rolldown bundler. Vite 7 (June 2025) still widely deployed.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST keep path aliases in sync between vite.config.ts and tsconfig.json - mismatches cause import resolution failures)
(You MUST use build.rolldownOptions in Vite 8+ - build.rollupOptions is a deprecated alias)
(You MUST use codeSplitting.groups for chunk splitting in Vite 8 - object-form manualChunks is removed, function-form deprecated)
(You MUST use build.modulePreload.polyfill instead of deprecated build.polyfillModulePreload)
(You MUST use Sass modern API (default in Vite 6+) - legacy API is removed in Vite 7+)
</critical_requirements>
Auto-detection: Vite, vite.config.ts, vite.config.js, manualChunks, advancedChunks, codeSplitting, loadEnv, rolldownOptions, rollupOptions, modulePreload, resolve.alias, resolve.tsconfigPaths, build.target, baseline-widely-available
When to use:
- Configuring Vite build tool for frontend applications
- Setting up path aliases with tsconfig sync
- Vendor chunk splitting for production builds
- Environment-specific build configuration (dev/staging/prod)
- Migrating from Vite 7 (Rollup) to Vite 8 (Rolldown)
- Configuring module preload, build targets, or Sass preprocessing
When NOT to use:
- Server-side build processes (Docker builds, CI/CD pipelines)
- Linter or formatter configuration (separate tooling skill)
- TypeScript compiler options (separate tooling skill)
Key patterns covered:
- Path aliases with tsconfig sync (and Vite 8
resolve.tsconfigPaths) - Vendor chunk splitting (
manualChunksfor Vite 7,codeSplittingfor Vite 8) - Environment-specific builds with
loadEnvanddefine - Module preload configuration
- Sass modern API configuration
- Environment API (experimental, primarily for framework authors)
- Build target selection (
baseline-widely-available)
Detailed resources:
- examples/core.md - Full code examples for all patterns
- reference.md - Quick-lookup tables, migration checklist, external links
<philosophy>
Philosophy
Vite should be fast, zero-config by default, and environment-aware. The build tool stays out of your way during development (instant HMR) and optimizes aggressively for production (chunk splitting, minification, tree-shaking).
When to use this skill:
- Configuring or optimizing Vite builds
- Setting up path aliases, chunk splitting, or environment configs
- Migrating between Vite major versions (7 to 8)
- Configuring Sass, build targets, or module preload
When NOT to use:
- Runtime application code (this is build-time configuration only)
- SSR meta-framework configuration (handled by meta-framework skills)
- CI/CD pipeline configuration
</philosophy>
<patterns>
Core Patterns
Pattern 1: Path Aliases
Configure path aliases in both vite.config.ts and tsconfig.json to eliminate deep relative imports. In Vite 8, use resolve.tsconfigPaths: true instead of manual resolve.alias.
// Vite 7: manual resolve.alias
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@components": path.resolve(__dirname, "./src/components"),
},
},
// Vite 8: built-in tsconfig path resolution
resolve: {
tsconfigPaths: true, // reads from tsconfig.json automatically
},
Key point: resolve.tsconfigPaths is disabled by default (performance cost). Enable only if using tsconfig paths. See examples/core.md for complete configs.
Pattern 2: Vendor Chunk Splitting
Split vendor dependencies into separate chunks for better caching. API differs between Vite 7 and 8.
// Vite 7: manualChunks (object form)
build: {
rollupOptions: {
output: {
manualChunks: {
"vendor": ["react", "react-dom"],
},
},
},
},
// Vite 8: codeSplitting.groups (regex-based)
build: {
rolldownOptions: {
output: {
codeSplitting: {
groups: [
{ name: "vendor", test: /[\\/]node_modules[\\/]react(-dom)?[\\/]/ },
],
},
},
},
},
Key point: In Vite 8, object-form manualChunks is removed and function-form is deprecated. Rolldown generates a runtime.js chunk alongside code-split groups. See examples/core.md for full examples.
Pattern 3: Environment-Specific Builds
Use loadEnv() for environment-aware configuration and define for build-time constants.
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
build: {
sourcemap: mode === "development",
minify: mode === "production",
},
};
});
Key point: The third argument to loadEnv() ("") loads all env vars, not just VITE_-prefixed ones. Use --mode flag for environment selection. See examples/core.md for full config with scripts.
Pattern 4: Module Preload Configuration
build: {
modulePreload: {
polyfill: false, // disable for modern-only targets
resolveDependencies: (filename, deps, { hostId, hostType }) => {
return deps.filter((dep) => !dep.includes("large-vendor"));
},
},
},
Key point: build.polyfillModulePreload is deprecated. Use build.modulePreload.polyfill (current API since Vite 6).
Pattern 5: Sass Configuration (Vite 6+)
css: {
preprocessorOptions: {
scss: {
// modern API is the default in Vite 6+ — no need to specify
additionalData: `@use "@/styles/variables" as *;`,
},
},
},
Key point: Legacy API (api: 'legacy') is removed in Vite 7+. Migrate @import to @use/@forward with namespaced access (variables.$color-primary).
Pattern 6: Environment API (Experimental)
Primarily for framework authors. Remains in RC phase as of Vite 8. Most apps do not need this.
environments: {
client: { build: { outDir: "dist/client" } },
ssr: { build: { outDir: "dist/server", ssr: true } },
},
See examples/core.md for full multi-environment config.
Pattern 7: Dev Server Proxy
const DEV_SERVER_PORT = 3000;
const API_PROXY_TARGET = "http://localhost:8000";
server: {
port: DEV_SERVER_PORT,
proxy: {
"/api": { target: API_PROXY_TARGET, changeOrigin: true },
},
},
</patterns>
<decision_framework>
Decision Framework
Vite Version Selection
Which Vite version?
├─ New project (March 2026+)?
│ └─ Vite 8 (Rolldown bundler, fastest builds) ✓
├─ Existing Vite 7 project?
│ ├─ Build performance is a bottleneck?
│ │ └─ YES → Migrate to Vite 8 (10-30x faster)
│ └─ NO → Stay on Vite 7 (stable, no migration needed)
└─ Existing Vite 6 project?
└─ Plan upgrade to Vite 7 first, then Vite 8
Chunk Splitting Strategy
How to split chunks?
├─ Vite 8 (Rolldown)?
│ ├─ Simple vendor separation?
│ │ └─ codeSplitting.groups with regex patterns ✓
│ └─ Complex splitting (size limits, shared modules)?
│ └─ codeSplitting with maxSize/minSize/minShareCount
├─ Vite 7 (Rollup)?
│ ├─ Simple vendor separation?
│ │ └─ manualChunks object form ✓
│ └─ Complex splitting logic?
│ └─ manualChunks function form
└─ Vite 7 with rolldown-vite (experimental)?
└─ advancedChunks.groups (renamed to codeSplitting in Vite 8)
Path Alias Strategy
How to configure path aliases?
├─ Vite 8?
│ ├─ All aliases match tsconfig paths?
│ │ └─ Use resolve.tsconfigPaths: true ✓
│ └─ Need aliases beyond tsconfig paths?
│ └─ Use resolve.alias (manual configuration)
├─ Vite 7 or earlier?
│ └─ Use resolve.alias + sync with tsconfig.json manually ✓
└─ Any version?
└─ ALWAYS keep tsconfig paths in sync with Vite aliases
Build Target Selection
Choosing build.target?
├─ Supporting legacy browsers (< Safari 16)?
│ └─ Use @vitejs/plugin-legacy
├─ Modern browsers only?
│ ├─ Smallest possible bundle?
│ │ └─ 'esnext'
│ └─ Otherwise → 'baseline-widely-available' (default) ✓
└─ Specific browser requirements?
└─ Use explicit array: ['chrome111', 'safari16.4']
See reference.md for quick-lookup tables and migration checklist.
</decision_framework>
<red_flags>
RED FLAGS
High Priority Issues:
- ❌ Using
build.rollupOptionsin Vite 8 (deprecated alias forbuild.rolldownOptions- may warn) - ❌ Using object-form
manualChunksin Vite 8 (removed; usecodeSplitting.groups) - ❌ Using deprecated
build.polyfillModulePreload(usebuild.modulePreload.polyfill) - ❌ Using deprecated
splitVendorChunkPlugin(removed in Vite 7+) - ❌ Using
target: 'modules'(removed in Vite 7; use'baseline-widely-available') - ❌ Using Sass legacy API
api: 'legacy'(removed in Vite 7+) - ❌ Path aliases in
vite.config.tsbut nottsconfig.json(or vice versa)
Medium Priority Issues:
- ⚠️ No vendor chunk splitting in production builds (large initial bundles)
- ⚠️ Same build config for all environments (slow dev builds, exposed source maps in prod)
- ⚠️ Hardcoded API URLs instead of environment variables
- ⚠️ Using Environment API in production apps (still RC phase)
- ⚠️ Function-form
manualChunksin Vite 8 (deprecated, migrate tocodeSplitting)
Common Mistakes:
- Forgetting to sync tsconfig paths with Vite resolve.alias (build works, IDE fails or vice versa)
- Committing
.envfiles with secrets (use.env.local, add to.gitignore) - Setting
minify: truein development mode (slows rebuilds significantly) - Always generating sourcemaps in production (exposes source code)
Gotchas & Edge Cases:
- Vite 8:
build.rollupOptionsis a deprecated alias forbuild.rolldownOptions- works but will warn - Vite 8: Rolldown generates a
runtime.jschunk when usingcodeSplitting.groups - Vite 8: Default browser targets: Chrome 111+, Edge 111+, Firefox 114+, Safari 16.4+
- Vite 8:
resolve.tsconfigPathsdisabled by default due to performance cost - Vite 8: Install size ~15MB larger than Vite 7 (lightningcss + Rolldown)
- Vite 8:
build.commonjsOptionsis a no-op (Rolldown handles CJS natively) - Vite 8: CSS minification uses Lightning CSS, JS minification uses Oxc (both replaced esbuild)
- Vite 8:
esbuildconfig option is deprecated - auto-converts tooxc, but not all options are supported (no property mangling, nosupportedoption) - Vite 7: Node.js 18 dropped - requires Node.js 20.19+ or 22.12+
- Vite 7: Sass legacy API completely removed
- Vite 7:
splitVendorChunkPluginremoved - Vite 7: Default target changed from
'modules'to'baseline-widely-available' - Rolldown:
advancedChunksrenamed tocodeSplittingin Vite 8 - Rolldown:
codeSplitting.maxSizeis a target, not a strict limit - Rolldown:
includeDependenciesRecursivelydefaults to true - may pull in more than expected .envfiles are loaded based on--modeflag, notNODE_ENVloadEnv()third argument ("") loads all env vars, not justVITE_-prefixed ones
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST keep path aliases in sync between vite.config.ts and tsconfig.json - mismatches cause import resolution failures)
(You MUST use build.rolldownOptions in Vite 8+ - build.rollupOptions is a deprecated alias)
(You MUST use codeSplitting.groups for chunk splitting in Vite 8 - object-form manualChunks is removed, function-form deprecated)
(You MUST use build.modulePreload.polyfill instead of deprecated build.polyfillModulePreload)
(You MUST use Sass modern API (default in Vite 6+) - legacy API is removed in Vite 7+)
Failure to follow these rules will cause build failures, broken imports, or deprecated API warnings.
</critical_reminders>