1、首先设置localhost和本地ip访问
在config文件下的index.js文件中,修改host为:host: ‘0.0.0.0’,
或者在package.json文件下"scripts"的"dev"值后新增–host 0.0.0.0",即:
“dev”: “webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 0.0.0.0”,
2、设置启动后终端显示localhost和network访问地址
修改build文件下compilationSuccessInfo的messages属性值:
compilationSuccessInfo: {
// 修改启动后终端显示localhost和network访问地址
messages: [
App runing at:
,
Local: http://localhost:${port}
,
Network: http://${require('ip').address()}:${port}
,
],
},
进行上面的2步的配置后,就可以进行localhost访问和ip地址访问了
Local: http://localhost:8080
Network: http://192.168.1.102:8080