# Fix "options has an unknown property 'contentBase'" in webpack-dev-server

Yes. An agent maps the removed devServer options to their webpack-dev-server 4 and 5 names, starts the dev server to prove the config loads, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/fix-dev-server-unknown-property-contentbase/webpack-dev-server/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

webpack-dev-server 4 replaced `contentBase` with `static` and started validating the whole `devServer` block against a schema. A config written for version 3 now stops before the server starts: `Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options has an unknown property 'contentBase'.` The message then lists the properties that are valid. The block is only read by `webpack serve`. A plain `webpack` build accepts any object under `devServer` and ignores it, so the mistake can sit in a repository for years while CI stays green.

commenthol/md-fileserver, a tool that serves Markdown files to a browser, shows how that happens. Its `package.json` asks for `webpack-dev-server` `^5.2.7`, and lines 58 to 62 of `webpack.config.js` still set `hot: true` and a `contentBase` array of two directories, the build output directory and `./test/html`. No script calls the dev server: `dev` is `webpack -w`, `build` is `webpack --mode production`, and the CI workflow runs `npm run ci`, which cleans, lints, builds and runs mocha on Node 24. The production build compiles with the stale option in place. Anyone who types `npx webpack serve` gets the error in the title, with webpack 5.112.2, webpack-cli 6.0.1 and webpack-dev-server 5.2.7 installed.

The agent installs dependencies, runs `npx webpack serve`, and reads the list of valid properties out of the error, since that list belongs to the installed version and is the reference for the rewrite. `contentBase` becomes `static`, and an array stays an array. Then it starts the server again instead of trusting the rename, because the schema reports what is wrong with the block it was given and other version 3 options may be waiting: `watchContentBase` moves to `static.watch`, `publicPath` and `writeToDisk` move under `devMiddleware`, `overlay` moves under `client`, `disableHostCheck` becomes `allowedHosts: 'all'`, and the `before` and `after` hooks become `setupMiddlewares`.

In this repository the renamed config starts, and the first lines of output raise two more points for the pull request. The server prints `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration`, because the config also pushes `new webpack.HotModuleReplacementPlugin({})` into `plugins` for non-production builds. And it reports serving static content from `./assets, ./test/html`, although there is no `test/html` directory in the repository. The agent removes the duplicate plugin only if `webpack -w` does not rely on it, drops or corrects the missing path, requests the served bundle once over HTTP, and stops the server.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Starting the webpack dev server in this repository fails with: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options has an unknown property 'contentBase'. Read package.json and the lockfile if there is one, and report the installed versions of webpack, webpack-cli and webpack-dev-server and every script that starts the dev server (webpack serve, webpack-dev-server, or a Node script that constructs the server). If no script starts it, say so. Find every webpack config, including ones merged with webpack-merge, and list each key under devServer. Install dependencies, run the dev server, and save the full error including the list of valid properties it prints. Rewrite the devServer block for the installed major version using that list: contentBase and its related options to static, middleware options to devMiddleware, client options to client, removed hooks to setupMiddlewares. Do not downgrade webpack-dev-server. After each change start the server again until it prints its listening address, then fetch the main bundle and the index page once and stop it. Report every warning the server prints at startup and fix the ones caused by the config, such as a HotModuleReplacementPlugin added by hand next to hot: true. Check that every static directory named in the config exists and report any that does not. Run the production build and the test script before and after to show they are unchanged. Open a pull request with a before and after table of the devServer options and the startup output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that changes the `devServer` block of the webpack config, and a `package.json` script only if one has to change with it. The description has a two-column table, the old option and what it became, and the startup output of the server after the change: the listening address, the directories it serves static content from, and any warnings that remain with the reason they were left.

A reviewer checks the table against how they use the server. `static` serves directories the way `contentBase` did, but options that moved under `devMiddleware` or `client` change shape, and a proxy or a custom middleware deserves a manual look in the browser. If the agent found that nothing in the repository starts the dev server, the description says so plainly, and the reviewer can decide that deleting the block is the better fix than repairing it.

The production bundle should not change. The description includes the result of the build and test scripts before and after, so a reviewer can confirm that the pull request touches development tooling only.

## Run it on every GitHub issue labelled dev-server

Because CI never starts a dev server, this breakage is reported by people: a new contributor follows the README, runs the server, and opens an issue with the schema error pasted in. Give the Project an automation with a `github` trigger on `issues.labeled`, filtered to the label your team uses, and a prompt that tells the agent to reproduce the command quoted in the issue and repair the config. The issue arrives after the prompt as event text. The trigger fires only for an issue opened by an owner, member or collaborator of the repository, so for a report from outside, a maintainer opens a tracking issue and labels that.

To stop the next occurrence earlier, ask for one more thing in the prompt: a CI step that starts the server, waits for the listening line and exits. The pull request then carries its own guard, and a later major upgrade of webpack-dev-server fails in CI on the day of the bump.

## Why run it on Rush?

A dev server config is checked by starting the server, and that is the step a quick local edit skips once the first error disappears. The schema error names the first problem. What follows it, a duplicate HMR plugin or a static directory that does not exist, only shows in the output of a server that actually started. The agent starts it in a sandbox with the versions your `package.json` resolves to, fetches the bundle, and keeps every line of that output in the session for the reviewer.

The sandbox also answers the question a laptop cannot: what a clean install gets today. A machine with an old `node_modules` may still hold webpack-dev-server 3 and run the old config happily while every fresh clone fails. Installing from nothing reproduces what a new contributor sees, which is the report you are trying to close.

## Frequently asked questions

### What replaces contentBase in webpack-dev-server 4 and 5?

`static`. It takes a path, an array of paths, or objects with `directory`, `publicPath` and `watch`. A `contentBase` array can be moved over as it is, and `contentBasePublicPath` and `watchContentBase` become the `publicPath` and `watch` fields of a `static` object.

### Why does my production build pass when the dev server config is invalid?

webpack itself does not validate the contents of `devServer`. Only webpack-dev-server reads the block, and only when you run `webpack serve`. A repository whose CI runs the build and the tests never loads it, which is how a version 3 option survives two major upgrades.

### Can I pin webpack-dev-server back to version 3 instead?

Version 3 accepts the old option names, but it is two major versions behind the current one, and going back means holding webpack-cli back with it. When the rest of the toolchain is already on webpack 5 with a current webpack-cli, renaming a few options is the smaller change. The request above tells the agent not to downgrade.

### The error lists only contentBase. Could there be more removed options?

Yes. The agent lists every key under `devServer` up front and starts the server again after each change, until it prints a listening address. Options that moved, such as `overlay`, `publicPath` or the `before` hook, are rewritten in the same pull request with the old and new form side by side.

## More webpack-dev-server jobs

- [Fix "'onBeforeSetupMiddleware' option is deprecated" from webpack-dev-server](https://getrush.ai/run/fix-onbeforesetupmiddleware-option-is-deprecated/webpack-dev-server/)
- [Fix "Error: Cannot find module 'webpack-cli/bin/config-yargs'" When Starting webpack-dev-server](https://getrush.ai/run/fix-webpack-cli-config-yargs-not-found/webpack-dev-server/)

## More jobs like this: Fix a bug from an alert

- [Fix "error:0308010C:digital envelope routines::unsupported" in a Create React App](https://getrush.ai/run/fix-digital-envelope-error/create-react-app/)
- [Fix "error:0308010C:digital envelope routines::unsupported" in a Vue CLI Build](https://getrush.ai/run/fix-digital-envelope-routines-unsupported/vue-cli/)
- [Fix a Broken Docker Build](https://getrush.ai/run/fix-docker-build/docker/)
- [Fix "docker-compose: command not found" in GitHub Actions](https://getrush.ai/run/fix-docker-compose-command-not-found/github-actions/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
