---
name: webpack-config-debugger
description: "Finds what is wrong with a webpack config that fails, builds slowly, or ships the wrong output: each issue tied to the line and rule it breaks, with a corrected snippet and the performance wins alongside. Use when a webpack build fails, rebuilds slowly, or ships wrong output and you need the config lines responsible and the corrected snippets. Do not use for explaining a config that works, or generating a fresh config for a new project. Related topics: coding, webpack."
---

# Webpack Config Debugger

Finds what is wrong with a webpack config that fails, builds slowly, or ships the wrong output: each issue tied to the line and rule it breaks, with a corrected snippet and the performance wins alongside.

## When to use

Use this skill when a webpack build fails, rebuilds slowly, or ships wrong output and you need the config lines responsible and the corrected snippets. Do not use it for explaining a config that works, or generating a fresh config for a new project.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Trace the symptom and error text back to the config line or rule responsible before auditing anything else.
3. Audit each focus area for the common faults (unmatched loader tests, wrong chain order, missing extensions, publicPath, version-mismatched plugin options).
4. For slow builds, check devtool choice, cache settings, and whether node_modules is being transpiled.
5. Classify every finding by severity and drop those below the chosen threshold.
6. Write each finding with its line, broken rule, explanation, and a corrected javascript snippet, or declare the config healthy.

## Inputs

- **Config file** (longer free text)
- **Symptom** (longer free text)
- **Target environment** (choose one: development, production, both)
- **Focus area** (choose any: entry, output, loaders, plugins, optimization, devServer, resolve)
- **Webpack version** (choose one: 5, 4, Not sure)
- **Minimum severity to report** (choose one: Critical only, Critical and warning, Everything including style)
- **Verbose explanations** (choose one: On, Off)

## Output

A markdown document with Summary of critical issues, Detailed findings by focus area with severity, and Corrected snippets as javascript blocks, in that order.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Webpack Config Debugger

Diagnose the webpack configuration below and give me the corrections.

- Config file: {{Config file}}
- Symptom: {{Symptom}}
- Target environment: {{Target environment}}
- Focus area: {{Focus area}}
- Webpack version: {{Webpack version}}
- Minimum severity to report: {{Minimum severity to report}}
- Verbose explanations: {{Verbose explanations}}

Start from the symptom and the error text, since webpack errors usually name the module or rule involved; trace that back to the config line. Then audit the focus areas for the common faults: a loader test that does not match the file extension in use, loaders chained in the wrong order, a missing loader for an imported file type, resolve.extensions missing .ts, an output.publicPath that breaks asset URLs, plugins instantiated with options from a different major version, splitChunks settings that produce one giant chunk, and devServer proxies that swallow errors. For slow builds, look for source-map choices, missing cache settings, and transpilation of node_modules. Classify each finding by severity: critical (build fails or output is wrong), warning (works but costs performance or correctness later), style.

For each finding give the config line if identifiable, the rule it breaks, a one or two sentence explanation (longer when verbose is on), and a corrected snippet in a fenced javascript block. When nothing at or above the chosen severity is found, say the config looks healthy for the target and list the remaining style notes.

### Output
Return a markdown document with three sections: Summary of critical issues (one line each), Detailed findings grouped by focus area with severity and the broken rule, and Corrected snippets as fenced javascript blocks, in that order.

## Pitfalls

- Fixing the loader test regex without checking the loader order, so the build still fails one rule later.
- Reporting webpack 4 style plugin options as correct on a webpack 5 config where the option was renamed or removed.
- Recommending source-map for production without noting it publishes the original source to every visitor.
