Problem : When learning webpack, the following problems occurred. When installing and running webpack-dev-server, the browser cannot access normally and throws 404.
Solution : Add relevant settings in webpack.config.js
module.exports={
mode:'development',
devServer: {
static:'./',//根目录,需要点击进入src才能查看
//static:path.join(__dirname, 'src'),//可以直接访问到src页面,实现页面的实时查看。
host: "localhost",
port: 8080,
hot: true,
},
}
success:
See another article for details