界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
数据与研究 · SKILL.md

webpack-plugin-authoring

webpack-plugin-authoring

【数据与研究】Writing webpack 5 plugins — hook selection (compiler vs compilation, tap vs tapAsync, processAssets stages), the asset pipeline (emitAsset, source classes, info metadata, source maps), watch-mode and persistent caching (file/context/missing/buildDependencies), plugin lifecycle (constructor purity, multi-compiler isolation, shutdown cleanup), schema-u…

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: webpack-plugin-authoring description: Writing webpack 5 plugins — hook selection (compiler vs compilation, tap vs tapAsync, processAssets stages), the asset pipeline (emitAsset, source classes, info metadata, source maps), watch-mode and persistent caching (file/context/missing/buildDependencies), plugin lifecycle (constructor purity, multi-compiler isolation, shutdown cleanup), schema-utils validation, WebpackError reporting, jest-worker parallelism, and compatibility patterns (compiler.webpack namespace, peerDependencies, getCompilationHooks WeakMap). Patterns are drawn from production plugins like mini-css-extract-plugin, terser-webpack-plugin, compression-webpack-plugin, and Next.js's webpack plugins. Trigger when writing, reviewing, or debugging webpack 5 plugins — even if the user doesn't explicitly mention "best practices" — anytime an apply(compiler) method is being written, hooks are being tapped, or a plugin imports from webpack-sources, the rules in this skill apply.

dot-skills Webpack 5 Plugins Best Practices

Comprehensive guide for writing correct, performant webpack 5 plugins. Contains 44 rules across 8 categories (8 hook + 7 asset + 5 cache + 5 life + 4 schema + 5 diag + 5 perf + 5 compat = 44), ordered by the authoring lifecycle: hook choice is the foundation, then asset manipulation, then caching/watch-mode correctness, then lifecycle hygiene, then user-facing concerns (schema validation, error reporting), then performance, then packaging.

Patterns are derived from webpack/webpack, the webpack-contrib plugin suite (mini-css-extract, terser, compression, copy, css-minimizer), and Next.js's webpack integration in vercel/next.js.

When to Apply

Reference these rules whenever:

  • Writing a new plugin (defining apply(compiler), picking which hook to tap)
  • Reviewing existing plugin code for correctness or performance
  • Debugging "why isn't my plugin's output showing up" — usually a hook/stage mismatch
  • Adding asset manipulation logic (processAssets, emitAsset, updateAsset)
  • Fixing watch-mode staleness or persistent-cache poisoning
  • Migrating a plugin from webpack 4 to webpack 5 (or supporting both)
  • Publishing a plugin to npm (export shape, peerDependencies, schema)

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Hook Selection & Tap PatternsCRITICALhook-
2Asset PipelineCRITICALasset-
3Caching & Watch ModeHIGHcache-
4Plugin Lifecycle & StateHIGHlife-
5Schema & Options ValidationMEDIUM-HIGHschema-
6Errors, Warnings & LoggingMEDIUM-HIGHdiag-
7Performance & ParallelismMEDIUMperf-
8Compatibility & PackagingLOW-MEDIUMcompat-

Quick Reference

1. Hook Selection & Tap Patterns (CRITICAL)

2. Asset Pipeline (CRITICAL)

3. Caching & Watch Mode (HIGH)

4. Plugin Lifecycle & State (HIGH)

5. Schema & Options Validation (MEDIUM-HIGH)

6. Errors, Warnings & Logging (MEDIUM-HIGH)

7. Performance & Parallelism (MEDIUM)

8. Compatibility & Packaging (LOW-MEDIUM)

How to Use

When writing or reviewing plugin code, scan AGENTS.md for the relevant category, then read the individual rule file for the full pattern and rationale.

Reference Files

FileDescription
references/_sections.mdCategory definitions, impact levels, descriptions
assets/templates/_template.mdTemplate for authoring new rules
metadata.jsonVersion, discipline, source references
我的收藏