I’m reading the webpack5 doc. In the document’s Guides -> Development -> Choosing a Development Tool -> Using webpack-dev-server,there is a tip as follows
webpack-dev-server serves bundled files from the directory defined in output.path, i.e., files will be available under http://[devServer.host]:[devServer.port]/[output.publicPath]/[output.filename]
but i can’t get bundles in the directory defined by output.path
firstly, I used the npx webpack
to generate files in the dist directory
then I modified dist/index.bundle.js to distinguish between index.bundle.js in memory
finally I start a server by npx webpack serve
and accessed localhost:8080/dev/index.bundle.js
I found it’s not the index.bundle.js in dist directory
├── assets
├── dist
│ ├── index.bundle.js
│ ├── index.html
│ └── runtime.bundle.js
├──src
│ └── index.js
└── webpack.config.js
// webpack.config.js
module.exports = {
mode: "development",
entry: {
index: path.resolve(__dirname, "./src/index.js")
},
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "/dev",
filename: "[name].bundle.js",
clean: true
},
plugins: [
new htmlWebpaclPlugin({
title: "webpack-dev-server"
})
],
devServer: {
static: path.resolve(__dirname, "./assets")
},
optimization: {
runtimeChunk: "single"
}
}
I don’t think there is any relationship between output.path and webpack dev server
user24948077 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.