yarn)Repository link if needed.
// webpack.config.js
const path = require('path');
module.exports = {
devServer: {
open: true,
openPage: [ 'static1', 'static2', 'static3' ],
contentBase: [ path.join(__dirname, 'static1'), path.join(__dirname, 'static2'), path.join(__dirname, 'static3') ],
contentBasePublicPath: [ '/static1', '/static2', '/static3' ],
}
}
// Directory structure
$ tree -I "node_modules"
.
โโโ package.json
โโโ src
โ โโโ index.js
โโโ static1
โ โโโ s1-dir1
โ โ โโโ index.html
โ โโโ s1-dir2
โ โ โโโ index.html
โ โโโ s1-dir3
โ โโโ index.html
โโโ static2
โ โโโ s2-dir1
โ โ โโโ index.html
โ โโโ s2-dir2
โ โ โโโ index.html
โ โโโ s2-dir3
โ โโโ index.html
โโโ static3
โ โโโ s3-dir1
โ โ โโโ index.html
โ โโโ s3-dir2
โ โ โโโ index.html
โ โโโ s3-dir3
โ โโโ index.html
โโโ webpack.config.js
โโโ yarn.lock
13 directories, 13 files
When running webpack-dev-server, three pages should be opened.
They should be the following links respectively:
Also, since devServer.serveIndex is true by default, these pages should list the directory structure of ./static1, ./static2, ./static3 with the same structure as the actual directory .



Just run webpeck-dev-server (version 3.11.0), and one should be able to reproduce this behavior.
Actually, I have read the lib/Server.js, and found the pull request and the code snippet for this bug.
Pull Request: https://github.com/webpack/webpack-dev-server/pull/2489 (Modified setupStaticFeature)
In this PR, contentBasePublicPath accepts multiple paths. It actually does, I can access the following links (status code 200):
However, in the following snippet, contentBasePublicPath is also used but not modified in the PR.
// ...
setupServeIndexFeature() {
// ...
if (Array.isArray(contentBase)) {
contentBase.forEach((item) => {
this.app.use(contentBasePublicPath, (req, res, next) => {
// serve-index doesn't fallthrough non-get/head request to next middleware
if (req.method !== 'GET' && req.method !== 'HEAD') {
return next();
}
serveIndex(item, { icons: true })(req, res, next);
});
});
}
// ...
}
// ...
If devServer.contentBasePublicPath is an array, it seems like serve-index will list all pages by the directory structure of the zeroth element (./static1), thus what I showed in the Actual Behavior.
I am not sure if I should create a new issue or not, but anyway, let me write them down first.
I tried to list a table by only checking the code. (Sorry, I don't have extra time to test them now.)
setupStaticFeature| contentBase | contentBasePublicPath | Current Behavior |
| ------------- | ------------- | ------------- |
| boolean: false | string / [string] | working, not pushed into runnableFeatures |
| number | string / [string] | working, showing deprecated |
| string | string | working |
| string | [string] | not working and not implemented |
| [string] | string | working |
| [string] | [string] | working |
setupServeIndexFeature| contentBase | contentBasePublicPath | Current Behavior |
| ------------- | ------------- | ------------- |
| boolean: false | string / [string] | working, not pushed into runnableFeatures |
| number | string / [string] | working, doing nothing |
| string | string | working |
| string | [string] | not working and not implemented |
| [string] | string | working |
| [string] | [string] | not working and not implemented |
setupWatchStaticFeature| contentBase | watchContentBase | Current Behavior |
| ------------- | ------------- | ------------- |
| any | false | working, not pushed into runnableFeatures |
| boolean: false | true | potential problem
running chokidar.watch(false, watchOptions) |
| number | true | working, throwing error |
| string | true | working |
| [string] | true | working |
runnableFeaturesIn setupFeatures, there is possibility to produce duplicated elements in runnableFeatures. It might be a potential problem.

WIP for v4, no fixed for v3, sorry
Do you mean the following tasks? Also, when will v4 be released?

Yes, no ETA, maybe end of the month
@LuckyWindsck Can you try beta-0?
Fixed in beta-0, now you can setup publicPath for the each statis https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json#L15 (they can be not only one), feel free to feedback
@alexander-akait
Sorry for late reply.
I was not familiar with the GitHub notification system so I miss your mention.
I just tried v4.0.0-beta.0 and it worked perfectly for my case.
Thank you very much.
$ git diff issue-opened:webpack.config.js issue-resolved:webpack.config.js




Most helpful comment
Yes, no ETA, maybe end of the month