Skip to content

serveIndex is now serving wrong directory if having multiple paths in contentBasePublicPath #2645

Description

@LuckyWindsck
  • Operating System: macOS Mojave (Version 10.14.6)
  • Node Version: v14.4.0
  • NPM Version: 6.14.4(I used yarn)
  • Yarn Version: 1.22.4
  • webpack Version: 4.43.0
  • webpack-dev-server Version: 3.11.0
  • Browser: Version 83.0.4103.97 (Official Build) (64-bit)
  • This is a bug
  • This is a modification request

Code

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

Expected Behavior

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 .

Actual Behavior

For Bugs; How can we reproduce the behavior?

Just run webpeck-dev-server (version 3.11.0), and one should be able to reproduce this behavior.

For Features; What is the motivation and/or use-case for the feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions