关于 unplugin
unplugin 是用于开发、集成和调试 unplugin 插件的 skill,围绕统一的 Rollup 风格 API,介绍构建工具支持、生命周期钩子及兼容性。
主要功能
- 01统一的 Rollup 风格插件 API
- 02构建工具集成指南
- 03钩子与上下文参考
- 04跨构建工具兼容性表
- 05过滤器与嵌套插件
- 06虚拟模块与输出资源
适用场景
- 01开发新的 unplugin
- 02将插件接入构建工具
- 03排查钩子行为问题
- 04查询跨构建工具 API 支持情况
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hairyf/ skills --skill unplugin安装后在 Claude Code 中输入/unplugin确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
GENERATION.mdreferences/best-practices-conventions.mdbest-practices-diagnostics.mdbest-practices-scaffolding.mdcore-api.mdcore-hook-compatibility.mdcore-hooks-and-context.mdcore-integration.mdcore-overview.mdfeatures-bundler-specific.mdfeatures-filters.mdfeatures-nested-plugins.mdfeatures-output-and-assets.mdfeatures-parsing.mdfeatures-virtual-modules.md详细介绍
Unplugin 提供了一套单一的 Rollup 风格插件 API,可运行于 Vite、Rollup、webpack、esbuild、Rspack、Rolldown、Farm 和 Bun。在实现新的 unplugin、集成已有的 unplugin,或调试跨打包工具的 hook/context 行为时,可使用这些技能。
该技能基于 unplugin v3.0.0,生成于 2026-01-30。
核心参考
| 主题 | 描述 | 参考 |
|---|---|---|
| 概述 | unplugin 是什么、支持的打包工具、何时使用 | core-overview |
| 核心 API | createUnplugin、工厂签名、各打包工具专用创建函数 | core-api |
| Hook 与 context | 生命周期 hook、过滤器、this.parse / emitFile / warn / error | core-hooks-and-context |
| Hook 兼容性 | 各打包工具对 hook 和 context 的支持表 | core-hook-compatibility |
| 集成 | 在 Vite、Rollup、webpack 等中安装和注册 | core-integration |
特性
| 主题 | 描述 | 参考 |
|---|---|---|
| 过滤器 | 用于 resolveId、transform、load 的 filter 选项(性能) | features-filters |
| 嵌套插件 | 从工厂函数返回插件数组 | features-nested-plugins |
| 打包工具专用 | meta.framework、逃生舱口(vite/webpack/esbuild/…)、createXxxPlugin | features-bundler-specific |
| 虚拟模块 | resolveId + load 模式;用于 load 的 filter | features-virtual-modules |
| 解析 | setParseImpl、this.parse;何时需要(esbuild、webpack 等) | features-parsing |
| 输出与资源 | emitFile(仅 EmittedAsset)、writeBundle(仅时机) | features-output-and-assets |
最佳实践
| 主题 | 描述 | 参考 |
|---|---|---|
| 约定 | unplugin- 前缀、关键字、默认 + 子路径导出 | best-practices-conventions |
| 诊断 | this.warn / this.error、UnpluginMessage 结构 | best-practices-diagnostics |
| 脚手架 | 模板(unplugin-starter)、在线试用、前置条件 | best-practices-scaffolding |
评论
支持 Markdown