webpack-plugin-recipes

v2026.09.24

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.

GitHub
Install command
npx skhub add pproenca/webpack-plugin-recipes
Markdown
SKILL.md

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
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

MIT

Source path

skills/.experimental/webpack-plugin-recipes

Default branch

master

Latest commit

cf93c57

Tree SHA

afbb575