@vitejs/plugin-vue

The official Vite plugin for compiling Vue Single File Components with fast HMR and full TypeScript support

Tool
npm
v6.0.10
684 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
86 /100 Excellent
Development Activity 88
Maintenance 88
Community 76
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 85
Code Quality 84
Innovation 78
Learning Curve 88

@vitejs/plugin-vue is the officially maintained Vite plugin that compiles Vue 3 .vue Single File Components into JavaScript modules Vite can serve and bundle. It hooks into Vite’s plugin pipeline to parse each SFC into its script, template, and style blocks, run them through vue/compiler-sfc, and wire up hot module replacement so component edits update in the browser almost instantly while preserving local state.

It is the plugin create-vite scaffolds into every Vue project by default, and it underpins the dev experience for Vue apps built on Vite, VitePress, and other Vite-based tooling. Beyond baseline compilation it supports scoped and CSS Modules styles, custom SFC blocks (e.g. <i18n>), Vue’s Custom Elements mode, and the newer Vapor compilation mode, all configurable through a single Options object passed to the plugin factory.

What You Get

  • A drop-in Vite plugin (plugins: [vue()]) that compiles .vue Single File Components with zero additional build configuration
  • Fast, state-preserving HMR driven by handleHotUpdate, which diffs script/template/style blocks to avoid unnecessary full reloads
  • Support for scoped CSS, CSS Modules, and custom SFC blocks (like <i18n>) via pluggable transform hooks
  • Vue Custom Elements compilation mode (*.ce.vue) for shipping standalone web components with inlined styles
  • Configurable script, template, and style passthrough options mapped directly onto vue/compiler-sfc’s compile APIs
  • Experimental Vapor mode support for compiling SFCs without the Virtual DOM runtime (Vue 3.6+)

Common Use Cases

  • Every new Vue 3 project scaffolded with npm create vite@latest -- --template vue or vue-ts, where the plugin is preconfigured
  • Vue component libraries that need defineCustomElement support to ship as standalone custom elements
  • SSR and static-site frameworks built on Vite (e.g. VitePress) that need .vue compilation for both client and server bundles
  • Projects using custom SFC blocks (YAML/JSON <i18n> blocks, <docs> blocks) processed by companion transform plugins
  • Teams tuning production bundle size by disabling Options API support or prod devtools/hydration-mismatch details via features

Under The Hood

Architecture — The plugin’s entry point (src/index.ts) returns a Vite Plugin<Api> object wiring resolveId, load, and transform hooks around a virtual-module scheme: a .vue file’s script, template, and style blocks are addressed as ?vue&type=script|template|style sub-requests. The main request path (transformMain in main.ts) parses the file into an SFCDescriptor via createDescriptor (backed by an LRU-style cache in utils/descriptorCache.ts), decides whether the template can be inlined into the script block (canInlineMain/isUseInlineTemplate), and stitches together the final module combining compiled script, template render function, and style/query imports, applying @jridgewell source-map remapping so devtools show original .vue source positions. handleHotUpdate.ts implements Vite’s HMR contract by diffing the previous and current SFCDescriptor (isEqualBlock, isOnlyTemplateChanged) to decide between template-only patches, style-only patches, or a full reload, and separately tracks TypeScript type-only dependencies (typeDepToSFCMap) so edits to imported .ts type files also trigger the right invalidation.

Tech Stack — Written in TypeScript (module type module), it delegates all actual Vue SFC parsing/compilation to vue/compiler-sfc (resolved dynamically per-project via resolveCompiler in compiler.ts to support version pinning), and depends on Vite’s own Plugin, Rollup.TransformPluginContext, and ModuleNode types for its hook signatures. Source-map composition uses @jridgewell/trace-mapping and @jridgewell/gen-mapping; module filtering uses @rolldown/pluginutils’ exactRegex/makeIdFiltersToMatchWithQuery helpers to scope the new Rolldown-aware filter API. It builds with tsdown to a single ESM entry (dist/index.mjs) and declares vite and vue as peer dependencies rather than bundling them, keeping the plugin thin and version-flexible within the monorepo’s pnpm catalog.

Code Quality — The package ships a small dedicated __tests__ unit-test file (Vapor-only-template handling) but the bulk of correctness is enforced by the monorepo’s 12+ Playwright-driven e2e suites under playground/ (vue, vue-jsx, vue-legacy, vue-lib, vue-custom-id, vue-asset-base, vue-sourcemap, ssr-vue, vue-server-origin, tailwind, tailwind-v3), each running real Vite dev servers and production builds against representative app fixtures and asserting on rendered output, HMR behavior, and generated assets. Source files are consistently typed against vue/compiler-sfc’s own types, deprecated options (customElements, script.propsDestructure) are kept working but marked @deprecated with migration comments rather than silently dropped, and the code enforces ESLint/oxfmt via pre-commit hooks (simple-git-hooks + lint-staged).

API Design — The public surface is a single default export, a factory function vuePlugin(options?: Options): Plugin<Api>, so adopting it is one line in vite.config.js. The Options interface groups configuration by concern (script, template, style map directly onto vue/compiler-sfc compile options; features groups newer toggles like propsDestructure, customElement, vapor, optionsAPI) and the plugin exposes a typed Api object (options, include, exclude, version) so other plugins in a chain can introspect or adjust its behavior. Deprecated top-level options are retained with clear @deprecated JSDoc pointing to their features.* replacement, minimizing breaking changes across major versions.

Used by 49 apps in this directory

Ruby
66%
Other

GitLab

Developer Tools · Devops

24,537

The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.

View details
87
Repo Health
86
Technical
65
Dependency
Built with
Ruby 66%
JavaScript 20%
Updated 1 weeks ago
Go
69%
Other

Hanko

Authentication · Security

9,045

Open source, self-hostable authentication platform with passkeys, SAML SSO, and OAuth — the privacy-first alternative to Auth0 and Clerk.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
Go 69%
TypeScript 27%
Updated 1 weeks ago
Rust
51%
Other

hoodik

File Storage · Security

1,539

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
77
Repo Health
71
Technical
63
Dependency
Built with
Rust 51%
TypeScript 34%
Vue 14%
Updated 1 weeks ago
Rust
37%
Other

Hook0

Devops

1,504

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
84
Repo Health
82
Technical
69
Dependency
Built with
Rust 37%
TypeScript 12%
Updated 1 weeks ago
TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 1 weeks ago
Python
74%
GPL 3.0

Frappe HR

Human Resources

8,954

Complete open-source HRMS for employee lifecycle, attendance, payroll, and performance — built on Frappe Framework with a mobile PWA.

View details
93
Repo Health
70
Technical
78
Dependency
Built with
Python 74%
JavaScript 15%
Updated 1 weeks ago
Vue
50%
GPL 3.0

IT-Tools

Developer Tools

40,954

A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.

View details
60
Repo Health
74
Technical
63
Dependency
Built with
Vue 50%
TypeScript 48%
Updated 1 weeks ago
Java
56%
Apache 2.0

Kestra

Automation · Data Engineering · Devops

29,967

Event-driven orchestration platform for data, AI, and infrastructure workflows — define everything in YAML, run anywhere at scale.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Java 56%
TypeScript 29%
Vue 14%
Updated 1 weeks ago
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,983

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers