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-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.
How do I install this agent skill?
npx skills add https://github.com/pproenca/dot-skills --skill webpack-plugin-recipesIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill is a professional cookbook containing 26 recipes for Webpack 5 plugins. It provides working code for security (secret leak prevention), performance (bundle budgeting), and developer experience (notifications, browser automation). The code snippets follow industry best practices and use well-known libraries and services.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
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
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Build-time Guardrails | CRITICAL | guard- |
| 2 | Build Metadata & Manifests | HIGH | meta- |
| 3 | Virtual Modules & Codegen | HIGH | virtual- |
| 4 | Code Transformation | MEDIUM-HIGH | transform- |
| 5 | Developer Experience | MEDIUM | dx- |
| 6 | Asset Pipeline | MEDIUM | assets- |
Quick Reference
1. Build-time Guardrails (CRITICAL)
guard-bundle-budget— Fail builds when initial JS exceeds a per-entry gzipped budgetguard-forbidden-imports— Fail builds when forbidden imports cross architectural boundariesguard-required-env-vars— Fail builds when required environment variables are missingguard-no-secrets-bundled— Fail builds when secret-shaped strings leak into client bundles
2. Build Metadata & Manifests (HIGH)
meta-inject-build-info— Inject__COMMIT__/__BUILD_TIME__into source via DefinePlugin + emitbuild-info.jsonmeta-asset-manifest— Emit chunk-grouped manifest mapping logical names → hashed filenamesmeta-license-notice— GenerateLICENSES.txtby walking the module graph (notnode_modules/)meta-sri-manifest— Compute SHA-384 SRI hashes per asset for CSP compliance
3. Virtual Modules & Codegen (HIGH)
virtual-module-from-memory— Resolvevirtual:Ximports to in-memory strings (Vite-style)virtual-routes-from-filesystem— Generate route map frompages/directory (Next.js-style)virtual-barrel-from-directory— Auto-generate barrel re-exports from a directoryvirtual-types-from-runtime— Emit.d.tsfrom runtime data (config files, JSON schemas)
4. Code Transformation (MEDIUM-HIGH)
transform-replace-library— Replacereactwithpreact/compatat resolve (with subpath handling)transform-strip-debug-helpers— StripdevAssert()/devLog()calls + dev-only imports from productiontransform-conditional-polyfill— Inject only the polyfills target browsers actually need (browserslist + core-js-compat)transform-banner-with-dynamic-content— Per-chunk banners with current year, version, git committransform-define-from-config— DriveDefinePluginsubstitutions from aflags/staging.json-style file
5. Developer Experience (MEDIUM)
dx-build-duration-report— Persist build durations, warn when current build is >30% slower than mediandx-notify-on-done— Desktop notification (local) + Slack webhook (CI) on build completedx-diff-changed-chunks— Print only the chunks that actually changed between rebuildsdx-open-browser-on-first-build— Open the dev-server URL AFTER first successful build (not before)
6. Asset Pipeline (MEDIUM)
assets-pre-compress-gzip-brotli— Emit.gz/.brsiblings for CDN-served pre-compressionassets-optimize-images— Optimize PNG/JPEG with imagemin + cache reuse across rebuildsassets-route-by-type— Organize emitted assets intojs//css//img//fonts/subdirectoriesassets-skip-empty-chunks— Delete the 0-byte chunks webpack/splitChunks/mini-css emit unnecessarilyassets-add-cache-busting-query— Append?v=<hash>to references of fixed-name assets (manifest.json, sw.js)
How to Use
When the user describes a webpack problem (or asks for a plugin):
- Identify the problem category (guardrail? metadata? codegen? transformation? dx? asset?)
- Open the matching recipe file — read the Problem section first to confirm it's the right recipe
- Use the Plugin section as a working starting point — adapt to the project's specifics
- Read How it works for the WHY behind each design choice (cross-references the authoring rules)
- 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
| File | Description |
|---|---|
| references/_sections.md | Category definitions and impact levels |
| assets/templates/_template.md | Template for authoring new recipes |
| metadata.json | Version and source references |
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/pproenca/dot-skills/webpack-plugin-recipes">View webpack-plugin-recipes on skillZs</a>