Skip to content

devServer can not show html but dir, with module.exports=array #2977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
lornally opened this issue Jan 25, 2021 · 14 comments
Closed
1 of 2 tasks

devServer can not show html but dir, with module.exports=array #2977

lornally opened this issue Jan 25, 2021 · 14 comments

Comments

@lornally
Copy link

lornally commented Jan 25, 2021

  • webpack version: 5.4.0
  • Node.js version: 15.5.0
  • Operating System: macos bigsur 11.1
  • Additional tools: vscode, coffeescript
  • NPM Version:7.3.0
  • webpack-dev-server Version: 3.11.0
  • Browser: chrome
  • This is a bug
  • This is a modification request

Code

# webpack.config.coffee
cmd = # here is another config

html = # here is config for html
	entry: d1: './src/d1.js'
	output:
		path: path.resolve __dirname, 'dist/html'
		filename: '[name].[contenthash].js'
	plugins: [
		new HtmlWebpackPlugin	title: 'Development'
	]
	devServer: contentBase: './dist/html'

module.exports=[html,cmd] # if i use this line, http://localhost:8080/ is ~/
module.exports=[html] # if i use this line, http://localhost:8080/ is right

Expected Behavior

http://localhost:8080/ show '~/', it should show the index.html of the website.

Actual Behavior

when i use "webpack serve", http://localhost:8080/ only show: '~/' (the blank directory)

For Bugs; How can we reproduce the behavior?

@alexander-akait
Copy link
Member

alexander-akait commented Jan 25, 2021

Again - with normal reproducible test repo (you can create git repo and provide example of the problem), I can't help you having only part of configurations, I will reopen it when you fix it

@lornally
Copy link
Author

thank you, this is my first issue:) now, this is my git: https://github.com/lornally/weppackserveissue

@lornally
Copy link
Author

how about it? do you need me push more?

@alexander-akait
Copy link
Member

devServer: contentBase: './dist/html', publicPath: '/dist/html'

@lornally
Copy link
Author

thank you:)

@lornally
Copy link
Author

do you really try this? this can not fix the bug. i have push it in git : https://github.com/lornally/weppackserveissue

@alexander-akait
Copy link
Member

What do you want? It shows index.html, please describe your issue, I can't understand you

@lornally
Copy link
Author

lornally commented Feb 3, 2021

# with this, http://localhost:8080/ allways show dir / , this is wrong
# i have up pic to git: https://raw.githubusercontent.com/lornally/weppackserveissue/main/printscreen/devserver.png
devServer:
	contentBase: './dist/html'
	publicPath: '/dist/html'


# if export this http://localhost:8080/ is right show index.ejs, this is right
# i have up pic to git: https://raw.githubusercontent.com/lornally/weppackserveissue/main/printscreen/show_index.png
module.exports= html

# if export this http://localhost:8080/ is only show dir ./, this is wrong
# i have up pic to git: https://raw.githubusercontent.com/lornally/weppackserveissue/main/printscreen/array_show_dir.png
module.exports = [ cmd, html ]

if you can not see the pic, pls down it from git

@alexander-akait
Copy link
Member

webpack serve --config-name site

@lornally
Copy link
Author

lornally commented Feb 3, 2021

thank you very much, but i got this error:

  • Configuration with name "site" was not found.

@alexander-akait
Copy link
Member

html =
        name: 'site'
	mode: 'development'
	devtool: 'inline-source-map'
	entry:
		d1: './src/d1.js',
		d2: './src/d2.js'

@lornally
Copy link
Author

lornally commented Feb 3, 2021

wow, thank you so much, "site" is key setting for this, thank you again, and where i can find relative doc for this?

@alexander-akait
Copy link
Member

https://webpack.js.org/api/cli/#configuration-options maybe we need couple examples, feel free to send a PR

@lornally
Copy link
Author

lornally commented Feb 3, 2021

really really thank you for your patient and time, thank you:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants