@4399ywkf/core 5.1.2 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +10 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2127,7 +2127,7 @@ var defaultConfig = {
|
|
|
2127
2127
|
strictMode: true,
|
|
2128
2128
|
dev: {
|
|
2129
2129
|
port: 3e3,
|
|
2130
|
-
host: "
|
|
2130
|
+
host: "127.0.0.1",
|
|
2131
2131
|
proxy: {},
|
|
2132
2132
|
https: false
|
|
2133
2133
|
},
|
|
@@ -4169,6 +4169,10 @@ function getNetworkAddress(port) {
|
|
|
4169
4169
|
}
|
|
4170
4170
|
return null;
|
|
4171
4171
|
}
|
|
4172
|
+
function displayHost(host) {
|
|
4173
|
+
if (host === "0.0.0.0" || host === "::") return "localhost";
|
|
4174
|
+
return host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
4175
|
+
}
|
|
4172
4176
|
var BAR_WIDTH = 30;
|
|
4173
4177
|
function renderBar(percent) {
|
|
4174
4178
|
const filled = Math.round(BAR_WIDTH * percent);
|
|
@@ -4270,7 +4274,7 @@ var DevPrinter = class {
|
|
|
4270
4274
|
* 打印服务器信息面板(dev 模式使用)
|
|
4271
4275
|
*/
|
|
4272
4276
|
printServerInfo() {
|
|
4273
|
-
const localUrl = `http
|
|
4277
|
+
const localUrl = `http://${displayHost(this._host)}:${this.port}/`;
|
|
4274
4278
|
const networkUrl = getNetworkAddress(this.port);
|
|
4275
4279
|
console.log(` ${chalk.bold(">")} Local: ${chalk.cyan(localUrl)}`);
|
|
4276
4280
|
if (networkUrl) {
|
|
@@ -4313,7 +4317,7 @@ function registerShortcuts(getPrinter, opts) {
|
|
|
4313
4317
|
getPrinter().printShortcuts();
|
|
4314
4318
|
break;
|
|
4315
4319
|
case "o": {
|
|
4316
|
-
const url = `http
|
|
4320
|
+
const url = `http://${displayHost(opts.getHost())}:${opts.getPort()}/`;
|
|
4317
4321
|
import("child_process").then((cp) => {
|
|
4318
4322
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
4319
4323
|
cp.exec(`${command} ${url}`);
|
|
@@ -4386,7 +4390,7 @@ async function build(options = {}) {
|
|
|
4386
4390
|
let rspackConfig = createRspackConfig(config, cwd, { isDev: false });
|
|
4387
4391
|
rspackConfig = await pluginManager.applyRspackConfigHooks(rspackConfig);
|
|
4388
4392
|
const pluginNames = pluginManager.getPluginNames();
|
|
4389
|
-
const printer = new DevPrinter("
|
|
4393
|
+
const printer = new DevPrinter("127.0.0.1", 0, pluginNames, true);
|
|
4390
4394
|
printer.printBanner();
|
|
4391
4395
|
printer.printBuildStart();
|
|
4392
4396
|
printer.updateProgress(0, "preparing");
|
|
@@ -4539,7 +4543,7 @@ async function startDevServer(cwd, config) {
|
|
|
4539
4543
|
await pluginManager.runBeforeDevServer();
|
|
4540
4544
|
let rspackConfig = createRspackConfig(config, cwd, { isDev: true });
|
|
4541
4545
|
rspackConfig = await pluginManager.applyRspackConfigHooks(rspackConfig);
|
|
4542
|
-
const host = config.dev.host || "
|
|
4546
|
+
const host = config.dev.host || "127.0.0.1";
|
|
4543
4547
|
const preferredPort = config.dev.port || 3e3;
|
|
4544
4548
|
const port = await getAvailablePort(preferredPort, host);
|
|
4545
4549
|
const pluginNames = pluginManager.getPluginNames();
|
|
@@ -4622,6 +4626,7 @@ async function dev(options = {}) {
|
|
|
4622
4626
|
};
|
|
4623
4627
|
registerShortcuts(() => current.printer, {
|
|
4624
4628
|
getPort: () => current.port,
|
|
4629
|
+
getHost: () => current.host,
|
|
4625
4630
|
onQuit: async () => {
|
|
4626
4631
|
console.log(chalk3.gray("\n Shutting down...\n"));
|
|
4627
4632
|
await shutdown();
|