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

webpack-plugin-recipes

webpack-plugin-recipes

【开发与工程】Use whenever you face a webpack-build problem that ends with needing to write a plugin — 26 production-shaped recipes covering bundle-size budgets, forbidden architectural imports, env-var validation, secret-leak prevention, build-info injection, asset manifests, license walking, SRI hashes, virtual modules (Vite-style), filesystem routing (Next.js-s…

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

技能说明

GitHub

name: webpack-plugin-recipes description: Use whenever you face a webpack-build problem that ends with needing to write a plugin — 26 production-shaped recipes covering bundle-size budgets, forbidden architectural imports, env-var validation, secret-leak prevention, build-info injection, asset manifests, license walking, SRI hashes, virtual modules (Vite-style), filesystem routing (Next.js-style), generated barrels, runtime-driven TS types, library replacement (react→preact), debug-stripping, conditional polyfills, dynamic banners, feature flags, build-duration regression tracking, desktop/Slack notifications, changed-chunks diffing, browser auto-open, gzip/brotli pre-compression, image optimization, type-based dist layout, empty-chunk cleanup, cache-busting query strings. Each recipe is a complete working plugin drawn from production patterns at Next.js, Storybook, webpack-contrib. Trigger when the user asks how to do X with webpack or whether a plugin exists for X. Companion to webpack-plugin-authoring.

dot-skills Webpack 5 Plugins Best Practices

Cookbook of 26 production-shaped webpack 5 plugins, organized by the problem they solve. Each recipe starts with a clearly defined problem statement ("here's what hurts without this"), shows the naive non-plugin approach, then provides a complete working plugin (60-150 lines) with explanation, variations, and "when NOT to use" guidance.

Companion to webpack-plugin-authoring — authoring teaches how to write any plugin correctly; recipes teach which plugin to write for a specific pain point. Recipes cross-reference the authoring rules they apply.

When to Apply

Reference these recipes whenever:

  • A team has a recurring build-time problem that "feels like it should be a plugin" (architecture rules, secret leak prevention, asset organization)
  • You need to integrate webpack output with downstream systems (SSR servers, CDNs, monitoring)
  • You're considering whether to write your own plugin OR adopt an existing one — these recipes show the underlying pattern so you can judge fit
  • Migrating from another bundler and need to recreate framework-style features (filesystem routing, virtual modules)
  • Onboarding new engineers to webpack plugin authoring — recipes give realistic, end-to-end examples

Recipe Categories by Priority

PriorityCategoryImpactPrefix
1Build-time GuardrailsCRITICALguard-
2Build Metadata & ManifestsHIGHmeta-
3Virtual Modules & CodegenHIGHvirtual-
4Code TransformationMEDIUM-HIGHtransform-
5Developer ExperienceMEDIUMdx-
6Asset PipelineMEDIUMassets-

Quick Reference

1. Build-time Guardrails (CRITICAL)

2. Build Metadata & Manifests (HIGH)

3. Virtual Modules & Codegen (HIGH)

4. Code Transformation (MEDIUM-HIGH)

5. Developer Experience (MEDIUM)

6. Asset Pipeline (MEDIUM)

How to Use

When the user describes a webpack problem (or asks for a plugin):

  1. Identify the problem category (guardrail? metadata? codegen? transformation? dx? asset?)
  2. Open the matching recipe file — read the Problem section first to confirm it's the right recipe
  3. Use the Plugin section as a working starting point — adapt to the project's specifics
  4. Read How it works for the WHY behind each design choice (cross-references the authoring rules)
  5. Check Variations for common adaptations and When NOT to use to confirm the fit

For learning plugin authoring patterns more broadly, pair with the webpack-plugin-authoring skill — its 44 rules teach the underlying APIs every recipe in this skill applies.

Reference Files

FileDescription
references/_sections.mdCategory definitions and impact levels
assets/templates/_template.mdTemplate for authoring new recipes
metadata.jsonVersion and source references
我的收藏