Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

webpack-plugin-recipes

/webpack-plugin-recipes

Dostarcza 26 produkcyjnych przepisów na pluginy Webpack: budżety rozmiaru bundla, zakazane importy architektoniczne, walidacja zmiennych środowiskowych, zapobieganie wyciekom sekretów, manifesty zasobów, hashe SRI i moduły wirtualne.

Repozytorium
dot-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
15.08.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
31
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 15.08.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Dostarcza 26 produkcyjnych przepisów na pluginy Webpack: budżety rozmiaru bundla, zakazane importy architektoniczne, walidacja zmiennych środowiskowych, zapobieganie wyciekom sekretów, manifesty zasobów, hashe SRI i moduły wirtualne.

Oryginalny opis (EN)

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,

Jak działa

  1. When to Apply
  2. Recipe Categories by Priority
  3. Quick Reference
  4. How to Use
  5. Reference Files
Sekcje z nagłówków SKILL.md, w oryginale · 94 linii, 754 słów
Podgląd SKILL.md
---
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`](../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`](references/guard-bundle-budget.md) — Fail builds when initial JS exceeds a per-entry gzipped budget
- [`guard-forbidden-imports`](references/guard-forbidden-imports.md) — Fail builds when forbidden imports cross architectural boundaries
- [`guard-required-env-vars`](references/guard-required-env-vars.md) — Fail builds when required environment variables are missing
- [`guard-no-secrets-bundled`](references/guard-no-secrets-bundled.md) — Fail builds when secret-shaped strings leak into client bundles

### 2. Build Metadata & Manifests (HIGH)

- [`meta-inject-build-info`](references/meta-inject-build-info.md) — Inject `__COMMIT__`/`__BUILD_TIME__` into source via DefinePlugin + emit `build-info.json`
- [`meta-asset-manifest`](references/meta-asset-manifest.md) — Emit chunk-grouped manifest mapping logical names → hashed filenames
- [`meta-license-notice`](references/meta-license-notice.md) — Generate `LICENSES.txt` by walking the module graph (not `node_modules/`)
- [`meta-sri-manifest`](references/meta-sri-manifest.md) — Compute SHA-384 SRI hashes per asset for CSP compliance

### 3. Virtual Modules & Codegen (HIGH)

- [`virtual-module-from-memory`](references/virtual-module-from-memory.md) — Resolve `virtual:X` imports to in-memory strings (Vite-style)
- [`virtual-routes-from-filesystem`](references/virtual-routes-from-filesystem.md) — Generate route map from `pages/` directory (Next.js-style)
- [`virtual-barrel-from-directory`](references/virtual-barrel-from-directory.md) — Auto-generate barrel re-exports from a directory
- [`virtual-types-from-runtime`](references/virtual-types-from-runtime.md) — Emit `.d.ts` from runtime data (config files, JSON schemas)

### 4. Code Transformation (MEDIUM-HIGH)

- [`transform-replace-library`](references/transform-replace-library.md) — Replace `react` with `preact/compat` at resolve (with subpath handling)
- [`transform-strip-debug-helpers`](references/transform-strip-debug-helpers.md) — Strip `devAssert()`/`devLog()` calls + dev-only imports from production
- [`transform-conditional-polyfill`](references/transform-conditional-polyfill.md) — Inject only the polyfills target browsers actually need (browserslist + core-js-compat)
- [`transform-banner-with-dynamic-content`](references/transform-banner-with-dynamic-content.md) — Per-chunk banners with current year, version, git commit
- [`transform-define-from-config`](references/transform-define-from-config.md) — Drive `DefinePlugin` substitutions from a `flags/staging.json`-style file

### 5. Developer Experience (MEDIUM)

- [`dx-build-duration-report`](references/dx-build-duration-report.md) — Persist build durations, warn when current build is >30% slower than median
- [`dx-notify-on-done`](references/dx-notify-on-done.md) — Desktop notification (local) + Slack webhook (CI) on build complete
- [`dx-diff-changed-chunks`](references/dx-diff-changed-chunks.md) — Print only the chunks that actually changed between rebuilds
- [`dx-open-browser-on-first-build`](references/dx-open-browser-on-first-build.md) — Open the dev-server URL AFTER first successful build (not before)

### 6. Asset Pipeline (MEDIUM)

- [`assets-pre-compress-gzip-brotli`](references/assets-pre-compress-gzip-brotli.md) — Emit `.gz`/`.br` siblings for CDN-served pre-compression
- [`assets-optimize-images`](references/assets-optimize-images.md) — Optimize PNG/JPEG with imagemin + cache reuse across rebuilds
- [`assets-route-by-type`](references/assets-route-by-type.md) — Organize emitted assets into `js/`/`css/`/`img/`/`fonts/` subdirectories
- [`assets-skip-empty-chunks`](references/assets-skip-empty-chunks.md) — Delete the 0-byte chunks webpack/splitChunks/mini-css emit unnecessarily
- [`assets-add-cache-busting-query`](references/assets-add-cache-busting-query.md) — 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):

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`](../webpack-plugin-authoring/) skill — its 44 rules teach the underlying APIs every recipe in this skill applies.

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions and impact levels |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for authoring new recipes |
| [metadata.json](metadata.json) | Version and source references |
Pliki w paczce (31)
  • AGENTS.md 9 KB
  • SKILL.md 8 KB
  • metadata.json 3 KB
  • assets/templates/_template.md 5 KB
  • references/_sections.md 3 KB
  • references/assets-add-cache-busting-query.md 8 KB
  • references/assets-optimize-images.md 9 KB
  • references/assets-pre-compress-gzip-brotli.md 9 KB
  • references/assets-route-by-type.md 7 KB
  • references/assets-skip-empty-chunks.md 8 KB
  • references/dx-build-duration-report.md 8 KB
  • references/dx-diff-changed-chunks.md 8 KB
  • references/dx-notify-on-done.md 8 KB
  • references/dx-open-browser-on-first-build.md 7 KB
  • references/guard-bundle-budget.md 7 KB
  • references/guard-forbidden-imports.md 8 KB
  • references/guard-no-secrets-bundled.md 8 KB
  • references/guard-required-env-vars.md 6 KB
  • references/meta-asset-manifest.md 8 KB
  • references/meta-inject-build-info.md 8 KB
  • references/meta-license-notice.md 9 KB
  • references/meta-sri-manifest.md 8 KB
  • references/transform-banner-with-dynamic-content.md 7 KB
  • references/transform-conditional-polyfill.md 8 KB
  • references/transform-define-from-config.md 8 KB
  • references/transform-replace-library.md 7 KB
  • references/transform-strip-debug-helpers.md 7 KB
  • references/virtual-barrel-from-directory.md 8 KB
  • references/virtual-module-from-memory.md 7 KB
  • references/virtual-routes-from-filesystem.md 8 KB
  • references/virtual-types-from-runtime.md 8 KB

Wersje

W bazie nie ma innych skilli o nazwie webpack-plugin-recipes.

Migawka bazy z 28.10.2026 · wersja paczki 52c8252c1c4c (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100webpack
    Obejmuje bundler Webpack: konfigurację, loadery, pluginy i optymalizację, przy pracy z projektami opartymi na Webpack lub migracji z niego.
  • 100frontend-bundler-config
    Konfiguruje budowanie frontendu w Vite, Webpack, esbuild lub Rollup: serwer deweloperski, code splitting, tree shaking, zasoby, zmienne środowiskowe i budżety rozmiaru paczki, z pomiarem przed i po.
  • 100webpack
    Pomaga w pracy z Webpack 5: bundlowanie zasobów, code splitting, loadery, pluginy, strategie cache, optymalizacja webpack.config.js i rozmiaru bundli, loadery Babel i TypeScript oraz Module Federation.
  • 84analyze-bundle
    Analizuje rozmiar bundla aplikacji webowej, by znaleźć, co go powiększa i jak go zmniejszyć, w tym wyjście webpack, build Vite, ciężkie zależności i możliwości tree-shakingu.
  • 95phy-bundle-size-audit
    Audytuje rozmiar paczek JavaScript i egzekwuje budżety: czyta statystyki webpack, Vite, Rollup i Next.js, wskazuje największe chunki, zduplikowane zależności i porażki tree-shakingu oraz generuje bramki CI.
  • 100vite
    Pomaga w pracy z Vite, narzędziem buildowym i serwerem deweloperskim z szybkim HMR i optymalizowanymi buildami: konfiguracja, dev server i build.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.