question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  • 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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
alexander-akaitcommented, Jun 13, 2020

Yes, no ETA, maybe end of the month

0reactions
LuckyWindsckcommented, Apr 21, 2021

@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

image

http://[::]:8080/static1/ image

http://[::]:8080/static2/ image

http://[::]:8080/static3/ image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack dev server does not recognize watchContentBase ...
When I run my server, I get the following error. Invalid options object. Dev Server has been initialized using an options object that...
Read more >
webpack/webpack - Gitter
Now, that webpack does no longer expose process to the build, if you wan't to have process in the build, you need to...
Read more >
webpack-dev-server | Yarn - Package Manager
Provide path to a webpack configuration file e.g. ./webpack.config.js. --config-name <value...> Name of the configuration to use. -m, --merge Merge two or moreΒ ......
Read more >
r3f-react-app - CodeSandbox
appJsConfig);\n\n if (hasTsConfig && hasJsConfig) {\n throw new Error(\n 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScriptΒ ...
Read more >
docs: eject from create-react-app… - Cardano Updates
absolute path (e.g. `src/Components/Button.js`) but we set that up with ... single-page apps that may serve index.html for nested URLs like /todos/42.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found