What are the problems with using webpack to build a local server?

I am learning about webpack today. Then learn about the problems with building a local server.

this is my configuration code:

module.exports = {

 devtool:"eval-source-map",
entry:  __dirname + "/app/main.js",//
output: {
    path: __dirname + "./public",// 
    filename: "bundle.js",
    devServer:{
        contentBase:"/public",
        historyApiFallback:true,
        inline:true
    }
}

}
this is the code for package.json:
{
"name": "webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {

"webpack": "^4.6.0"

},
"devDependencies": {

"webpack-cli": "^2.1.2",
"webpack-dev-server": "^3.1.4"

},
"scripts": {

"start": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"server": "webpack-dev-server --open"

},
"author": ",
" license ":" ISC "
}
after reading the error report, I really didn"t understand it. I searched the Internet for a long time, but I still didn"t get it. Please give me your advice.

Mar.07,2021

is your devServer configuration written in output? The wrong message has been made very clear.


devServer:{
        contentBase:"/public",
        historyApiFallback:true,
        inline:true
    }

should not be placed in output, it should be at the same level as output

Menu