Skip to content

Commit

Permalink
perf: set the localHostname as localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
GiveMe-A-Name committed Apr 17, 2023
1 parent 45f2e17 commit c8632d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/builder/builder-shared/src/apply/output.ts
Expand Up @@ -83,7 +83,7 @@ function getPublicPath({
const hostname = context.devServer?.hostname || DEFAULT_DEV_HOST;
const port = context.devServer?.port || DEFAULT_PORT;
if (hostname === DEFAULT_DEV_HOST) {
const localHostname = `127.0.0.1`;
const localHostname = `localhost`;
// If user not specify the hostname, it would use 0.0.0.0
// The http://0.0.0.0:port can't visit in windows, so we shouldn't set publicPath as `//0.0.0.0:${port}/`;
// Relative to docs:
Expand Down
Expand Up @@ -9,7 +9,7 @@ This config is only used in the development environment. In the production envir

#### Boolean Type

If `assetPrefix` is set to `true`, the URL prefix will be `//ip:port/`:
If `assetPrefix` is set to `true`, the URL prefix will be `//localhost:port/`:

```js
export default {
Expand All @@ -22,7 +22,7 @@ export default {
The script URL will be:

```js
<script defer src="//${ip}:8080/static/js/main.js"></script>
<script defer src="//localhost:8080/static/js/main.js"></script>
```

If `assetPrefix` is set to `false` or not set, `/` is used as the default value.
Expand Down
Expand Up @@ -9,7 +9,7 @@

#### Boolean 类型

如果设置 `assetPrefix``true`,Builder 会自动计算出 `//ip:port/` 作为 URL 前缀:
如果设置 `assetPrefix``true`,Builder 会使用 `//localhost:port/` 作为 URL 前缀:

```js
export default {
Expand All @@ -22,7 +22,7 @@ export default {
对应 JS 文件在浏览器中加载的地址如下:

```js
<script defer src="//${ip}:8080/static/js/main.js"></script>
<script defer src="//localhost:8080/static/js/main.js"></script>
```

如果设置 `assetPrefix``false` 或不设置,则默认使用 `/` 作为访问前缀。
Expand Down

0 comments on commit c8632d3

Please sign in to comment.