From fe92a26e31e43f33e5eeb4e6ae282d5050ad9943 Mon Sep 17 00:00:00 2001 From: ckken Date: Thu, 8 Apr 2021 18:38:15 +0800 Subject: [PATCH] feat(release): v1.8.15 --- packages/emp-cli/helpers/serveTool.js | 7 +++++++ packages/emp-cli/package.json | 2 +- packages/emp-cli/scripts/dev.js | 6 +++--- packages/emp-cli/webpack/config/devServer.js | 3 +-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/emp-cli/helpers/serveTool.js b/packages/emp-cli/helpers/serveTool.js index 73a42cb5..1933a12a 100644 --- a/packages/emp-cli/helpers/serveTool.js +++ b/packages/emp-cli/helpers/serveTool.js @@ -10,7 +10,14 @@ function getHostname(hostname) { } return hostname } +function getDevHost(host) { + if (!host) { + host = internalIp.v4.sync() || internalIp.v6.sync() || 'localhost' + } + return host +} module.exports = { getHostname, + getDevHost, } diff --git a/packages/emp-cli/package.json b/packages/emp-cli/package.json index e582eb02..fff4fad7 100644 --- a/packages/emp-cli/package.json +++ b/packages/emp-cli/package.json @@ -1,6 +1,6 @@ { "name": "@efox/emp-cli", - "version": "1.8.14", + "version": "1.8.15", "keywords": [ "react", "module federation", diff --git a/packages/emp-cli/scripts/dev.js b/packages/emp-cli/scripts/dev.js index 2402fa41..427565a6 100644 --- a/packages/emp-cli/scripts/dev.js +++ b/packages/emp-cli/scripts/dev.js @@ -4,7 +4,7 @@ const Webpack = require('webpack') const WebpackDevServer = require('webpack-dev-server') const openBrowser = require('../helpers/openBrowser') // const downloadRemoteFile = require('../helpers/downloadRemoteFile') -const {getHostname} = require('../helpers/serveTool') +const {getHostname, getDevHost} = require('../helpers/serveTool') module.exports = async args => { const {src, public, open, remote} = args await setPaths({src, public}) @@ -22,8 +22,8 @@ module.exports = async args => { // const compiler = Webpack(config) const server = new WebpackDevServer(compiler, config.devServer) - const host = getHostname(config.devServer.host) || 'localhost' - server.listen(config.devServer.port, host, err => { + const host = getDevHost(config.devServer.host) + server.listen(config.devServer.port, '0.0.0.0', err => { if (err) { console.error(err) return diff --git a/packages/emp-cli/webpack/config/devServer.js b/packages/emp-cli/webpack/config/devServer.js index 607ff772..87c65304 100644 --- a/packages/emp-cli/webpack/config/devServer.js +++ b/packages/emp-cli/webpack/config/devServer.js @@ -8,8 +8,7 @@ module.exports = (env, {hot, open, progress}) => { // compress: true, // host: '0.0.0.0', // host: 'localhost', - //::TODO 设置后 localhost 不能访问 - host: 'local-ip', + // host: 'local-ip', port: 8000, // contentBase: [public], // contentBasePublicPath :'/',//定义静态路径的别名