Imported from miyaoka/vite-plugin-doc-block (
AGENTS.md). Install upstream withnpx skills add miyaoka/vite-plugin-doc-block. Copyright stays with the author.
vite-plugin-doc-block
Overview
Vite plugin that strips <doc> custom blocks from Vue SFC.
Commands
pnpm install # Install dependencies
pnpm build # Build
pnpm dev # Build in watch mode
pnpm lint # oxlint (type-aware) + oxfmt --check
pnpm fix # Auto-fix lint violations and format
Structure
src/index.ts- Plugin implementationtsdown.config.ts- Build configurationdist/- Build output (ESM + CJS)
How it works
- Runs before vite-plugin-vue-inspector via
enforce: "pre" - Parses SFC using
vue/compiler-sfc'sparse - Finds blocks where
type === "doc"incustomBlocks - Removes matching blocks via string replacement
- Injects a scan-only plugin into
optimizeDeps.rolldownOptions.pluginsvia theconfighook (#330). Vite's dependency scan bypasses the plugin pipeline and regex-extracts<script>from raw files, so a literal<script>inside a doc block breaks the scan. For SFCs with doc blocks, the scan plugin parses them with the real SFC parser and exposes each script block as its own virtual module — same design as Vite's built-in scan loader (Vite 8+ only; esbuild-based Vite 5–7 ignores the option)
Release
PR-based. Never push to main directly; CI handles the publish.
- Bump the version:
npm version <patch|minor|major> --no-git-tag-version(updatespackage.jsononly) - Open a PR labeled
releaseand merge it intomain - After merge, create a GitHub Release on
main's latest commit:gh release create vX.Y.Z --target main --generate-notes - Publishing the Release triggers
.github/workflows/publish.yml(on: release: published), which runsnpm publish --provenance(OIDC trusted publishing) - Release notes are GitHub's auto-generated PR list;
.github/release.ymlexcludes renovate[bot] andrelease-labeled PRs