🔧

sv コマンドについて調べた

に公開
2025/12/15

この記事は Svelte Advent Calendar 2025 の12日目の記事です。11日目は nazo6 さんの SvelteKitでOG画像を生成する でした。

導入

アドベント何か書きたいなーと思っていたところ、「そういえば sv 何となく使ってるけどちゃんとわかってないな」と思い立ち、sv コマンドについて改めて調べてみました。

sv とは?

scaffold, add-on (integration), migration の機能を含む CLI です。

公式ブログの2024年10月24日の記事 Introducing the new Svelte CLI で新機能として紹介されました。同時期に公式ドキュメントも sv コマンドを使うように書き換わっています。

scaffold

sv create で対話的に SvelteKit プロジェクトを新規作成します。

% npx sv create

┌  Welcome to the Svelte CLI! (v0.10.8)
│
◇  Where would you like your project to be created?
│  my-sv
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◇  What would you like to add to your project? (use arrow keys / space
bar)
│  none
│
◆  Project created
│
◇  Which package manager do you want to install dependencies with?
│  bun
│
│  bun x sv create --template minimal --types ts --install bun my-sv
│
◆  Successfully installed dependencies with bun
│
◇  What's next? ───────────────────────────────╮
│                                              │
│  📁 Project steps                            │
│                                              │
│    1: cd my-sv                               │
│    2: bun run dev --open                     │
│                                              │
│  To close the dev server, hit Ctrl-C         │
│                                              │
│  Stuck? Visit us at https://svelte.dev/chat  │
│                                              │
├──────────────────────────────────────────────╯
│
└  You're all set!

以下で軽く選択項目について補足します。

template

◆  Which template would you like?
│  ● SvelteKit minimal (barebones scaffolding for your new app)
│  ● SvelteKit demo (showcase app with a word guessing game that wos
│  ● Svelte library (setup with svelte-package to help correctly packageyour library)
  • minimal と demo の違いは、demo に SvelteKit の Counter の実装例が入っているくらいで、それ以外はほぼ同じ構成なようです。
  • svelte library についても、 SvelteKit に svelte ライブラリ開発用のパッケージングツールが含まれる形になっているため、SvelteKit がインストールされます (参考: Packaging ) 。

Add-on

公式で外部ツールとの統合・初期設定までサポートしてくれます。ありがたいですね。

以下、現在選択可能な Add-on です。

◆  What would you like to add to your project? (use arrow keys / space
bar)
│  ◻ prettier (formatter - https://prettier.io)
│  ◻ eslint (linter - https://eslint.org)
│  ◻ vitest (unit testing - https://vitest.dev)
│  ◻ playwright (browser testing - https://playwright.dev)
│  ◻ tailwindcss (css framework - https://tailwindcss.com)
│  ◻ sveltekit-adapter (deployment -https://svelte.dev/docs/kit/adapters)
│  ◻ devtools-json (devtools json -https://github.com/ChromeDevTools/vite-plugin-devtools-json)
│  ◻ drizzle (database orm - https://orm.drizzle.team)
│  ◻ lucia (auth guide - https://lucia-auth.com)
│  ◻ mdsvex (svelte + markdown - https://mdsvex.pngwn.io)
│  ◻ paraglide (i18n -https://inlang.com/m/gerre34r/library-inlang-paraglideJs)
│  ◻ storybook (frontend workshop - https://storybook.js.org)
│  ◻ mcp (Svelte MCP - https://svelte.dev/docs/mcp)
│

eslint や tailwindcss などの定番ツール以外にも気になるアドオンがありますが、それぞれ単体で記事にできそうなので、ここでは深追いしないでおきましょう。

Add-on (integration)

sv add コマンドで sv create にもあった add-on を既存プロジェクトに追加できます。

例:

% npx sv add tailwindcss

┌  Welcome to the Svelte CLI! (v0.10.8)
│
◇  Which plugins would you like to add?
│  typography
│
◆  Successfully setup add-ons: tailwindcss
│
◇  Which package manager do you want to install dependencies with?
│  bun
│
│  bun x sv add tailwindcss="plugins:typography" --install bun
│
◆  Successfully installed dependencies with bun
│
└  You're all set!

上記コマンドを実行することで、vite.config.ts に vite plugin が追加されているのが確認できます。

import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

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

migrate

sv migrate で諸々のマイグレーションが実行できます。

個人的に最初 svelte5 専用だと思っていましたが、 self-closing-tags や svelte-4 などのマイグレーションもこのコマンドに統合されているようです。

詳しくは ドキュメント をご参照ください。

おまけ

公式のアドベント Day-2 で紹介されていますが、 sv create --from-playground <url> で svelte-playground からプロジェクトをインポートする機能が追加されたみたいです。その他 add-on の追加もありそうなので今後に期待ですね。

参考

Discussion