feat: 支持局域网可访问,用ifconfig/ipconfig获取本机ip

This commit is contained in:
maxmon 2023-04-13 23:27:38 +08:00
parent 9cf736ba33
commit 25684c211d
2 changed files with 5 additions and 5 deletions

View File

@ -78,15 +78,15 @@ module.exports = new Promise((resolve, reject) => {
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
let host = devWebpackConfig.devServer.host === '0.0.0.0' ? 'localhost' : devWebpackConfig.devServer.host
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
messages: [`Your application is running here: http://${host}:${port}`]
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)

View File

@ -18,7 +18,7 @@ module.exports = {
},
// Various Dev Server settings
host: '127.0.0.1', // can be overwritten by process.env.HOST
host: '0.0.0.0', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,