---
name: webpack-config-validator
description: "A pre-build audit of a webpack config against the rules you choose: duplicate loaders, deprecated plugins, missing mode, source map gaps, and schema mistakes, reported by severity so it can go straight into CI logs or a PR comment. Use when a webpack config needs a pre-build audit for duplicate loaders, deprecated plugins, a missing mode, and source map settings, with every finding reported by severity. Do not use for performance tuning, documenting a config, or debugging a build that already fails with a stack trace. Related topics: coding, webpack."
---

# Webpack Config Validator

A pre-build audit of a webpack config against the rules you choose: duplicate loaders, deprecated plugins, missing mode, source map gaps, and schema mistakes, reported by severity so it can go straight into CI logs or a PR comment.

## When to use

Use this skill when a webpack config needs a pre-build audit for duplicate loaders, deprecated plugins, a missing mode, and source map settings, with every finding reported by severity. Do not use it for performance tuning, documenting a config, or debugging a build that already fails with a stack trace.

## 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. Check the schema first: misspelled or unknown option keys, wrong value types, and rule tests that match nothing, since these fail silently.
3. Apply each selected rule and record every violation with its config path, what is wrong, and the one-line fix.
4. Confirm each named plugin is instantiated with its required options and in a sensible order.
5. Assign a severity to each finding and drop anything below the threshold.
6. Write the report in the chosen format with Summary, Errors, Warnings, and Recommendations, opening with a pass or fail verdict.

## Inputs

- **Webpack config** (longer free text)
- **Target environment** (choose one: development, production, test)
- **Rules to enforce** (choose any: No duplicate loaders, No deprecated plugins, Enforce source maps, Enforce mode set)
- **Plugins to verify** (longer free text)
- **Severity threshold** (choose one: error, warning, info)
- **Output format** (choose one: plain text, markdown, JSON)

## Output

A report in plain text, markdown, or JSON with four sections: Summary (counts by severity and a verdict), Errors, Warnings, Recommendations, each finding carrying a config path and a fix.

## Prompt template

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

### Webpack Config Validator

Audit the webpack configuration below and report every problem before I run the build.

- Webpack config: {{Webpack config}}
- Target environment: {{Target environment}}
- Rules to enforce: {{Rules to enforce}}
- Plugins to verify: {{Plugins to verify}}
- Severity threshold: {{Severity threshold}}
- Output format: {{Output format}}

Validate in three passes. First, schema: option names that webpack will reject or ignore (a misspelled key fails silently and is the commonest bug), wrong value types, and rules whose test regex never matches a real file. Second, the selected rules: a loader applied twice to the same files, plugins that are deprecated or replaced in the current webpack major, a missing or wrong mode for the target environment, and devtool settings that are absent where source maps are enforced or that leak source in production. Third, the named plugins: confirm each is instantiated, required options are set, and the order is sensible. Classify each finding as error (build breaks or output is wrong), warning (works but risky or wasteful), or info (style), and include only findings at or above the threshold. For each, give the config path, what is wrong, and the one-line fix. Return the report in the chosen format with four sections: Summary (counts by severity and a pass or fail verdict), Errors, Warnings, Recommendations, ready to paste into documentation or CI output.

## Pitfalls

- Flagging a loader as duplicated when the two rules have different test patterns or oneOf branches, a false positive that erodes trust in the report.
- Treating a missing devtool as fine in production when source maps are enforced, so the first production stack trace is unreadable.
- Reporting on plugin names from memory instead of checking the pasted config, which lists plugins the config does not use.
