提交 af2df6ba 编写于 作者: fxy060608's avatar fxy060608

build(deps): bump vite from 2.6.3 to 2.6.5

上级 3a156fff
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"packages/*" "packages/*"
], ],
"scripts": { "scripts": {
"build": "node scripts/build.js && npm run test", "build": "node scripts/build.js",
"build:h5": "node scripts/build.js uni-app uni-cli-shared uni-h5 uni-i18n uni-stat uni-shared uni-h5-vite vite-plugin-uni", "build:h5": "node scripts/build.js uni-app uni-cli-shared uni-h5 uni-i18n uni-stat uni-shared uni-h5-vite vite-plugin-uni",
"build:app": "node scripts/build.js uni-app-plus uni-app-vite uni-app-vue uni-cli-nvue", "build:app": "node scripts/build.js uni-app-plus uni-app-vite uni-app-vue uni-cli-nvue",
"build:mp": "node scripts/build.js uni-mp-vue uni-mp-alipay uni-mp-baidu uni-mp-qq uni-mp-toutiao uni-mp-weixin uni-mp-kuaishou uni-quickapp-webview", "build:mp": "node scripts/build.js uni-mp-vue uni-mp-alipay uni-mp-baidu uni-mp-qq uni-mp-toutiao uni-mp-weixin uni-mp-kuaishou uni-quickapp-webview",
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
"semver": "^7.3.4", "semver": "^7.3.4",
"ts-jest": "^27.0.3", "ts-jest": "^27.0.3",
"typescript": "^4.4.3", "typescript": "^4.4.3",
"vite": "^2.6.3", "vite": "^2.6.5",
"vue": "^3.2.20", "vue": "^3.2.20",
"yorkie": "^2.0.0" "yorkie": "^2.0.0"
}, },
......
...@@ -32,6 +32,6 @@ ...@@ -32,6 +32,6 @@
"compression": "^1.7.4", "compression": "^1.7.4",
"cypress": "^7.3.0", "cypress": "^7.3.0",
"serve-static": "^1.14.1", "serve-static": "^1.14.1",
"vite": "^2.6.3" "vite": "^2.6.5"
} }
} }
...@@ -2205,7 +2205,7 @@ verror@1.10.0: ...@@ -2205,7 +2205,7 @@ verror@1.10.0:
core-util-is "1.0.2" core-util-is "1.0.2"
extsprintf "^1.2.0" extsprintf "^1.2.0"
vite@^2.6.3: vite@^2.6.5:
version "2.6.5" version "2.6.5"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.5.tgz#c4d25972e2f7371e682da86828722ddf5126f3d1" resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.5.tgz#c4d25972e2f7371e682da86828722ddf5126f3d1"
integrity sha512-vavXMChDUb4Oh4YunrK9BrH5Ox74cu0eOp0VuyI/iqFz1FqbWD72So2c9I87lLL2n0+6tFPV5ijow60KrtxuZg== integrity sha512-vavXMChDUb4Oh4YunrK9BrH5Ox74cu0eOp0VuyI/iqFz1FqbWD72So2c9I87lLL2n0+6tFPV5ijow60KrtxuZg==
......
...@@ -60,6 +60,7 @@ export const UniH5Plugin: UniVitePlugin = { ...@@ -60,6 +60,7 @@ export const UniH5Plugin: UniVitePlugin = {
}, },
define: createDefine(env.command, config), define: createDefine(env.command, config),
server: { server: {
host: true,
fs: { fs: {
strict: false, strict: false,
}, },
......
import os from 'os'
import { AddressInfo, Server } from 'net'
import chalk from 'chalk'
import { Logger, ResolvedConfig } from 'vite'
export function printHttpServerUrls(
server: Server,
config: ResolvedConfig
): void {
const address = server.address()
const isAddressInfo = (x: any): x is AddressInfo => x?.address
if (isAddressInfo(address)) {
const hostname = resolveHostname(true /*config.server.host*/)
const protocol = config.server.https ? 'https' : 'http'
printServerUrls(
hostname,
protocol,
address.port,
config.base,
config.logger.info
)
}
}
function printServerUrls(
hostname: Hostname,
protocol: string,
port: number,
base: string,
info: Logger['info']
): void {
if (hostname.host === '127.0.0.1') {
const url = `${protocol}://${hostname.name}:${chalk.bold(port)}${base}`
info(` > Local: ${chalk.cyan(url)}`)
if (hostname.name !== '127.0.0.1') {
info(` > Network: ${chalk.dim('use `--host` to expose')}`)
}
} else {
Object.values(os.networkInterfaces())
.flatMap((nInterface) => nInterface ?? [])
.filter((detail) => detail && detail.address && detail.family === 'IPv4')
.map((detail) => {
const type = detail.address.includes('127.0.0.1')
? 'Local: '
: 'Network: '
const host = detail.address.replace('127.0.0.1', hostname.name)
const url = `${protocol}://${host}:${chalk.bold(port)}${base}`
return ` > ${type} ${chalk.cyan(url)}`
})
.forEach((msg) => info(msg))
}
}
export interface Hostname {
// undefined sets the default behaviour of server.listen
host: string | undefined
// resolve to localhost when possible
name: string
}
export function resolveHostname(
optionsHost: string | boolean | undefined
): Hostname {
let host: string | undefined
if (
optionsHost === undefined ||
optionsHost === false ||
optionsHost === 'localhost'
) {
// Use a secure default
host = '127.0.0.1'
} else if (optionsHost === true) {
// If passed --host in the CLI without arguments
host = undefined // undefined typically means 0.0.0.0 or :: (listen on all IPs)
} else {
host = optionsHost
}
// Set host name to localhost when possible, unless the user explicitly asked for '127.0.0.1'
const name =
(optionsHost !== '127.0.0.1' && host === '127.0.0.1') ||
host === '0.0.0.0' ||
host === '::' ||
host === undefined
? 'localhost'
: host
return { host, name }
}
import os from 'os'
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import chalk from 'chalk' import chalk from 'chalk'
...@@ -8,11 +7,10 @@ import { ...@@ -8,11 +7,10 @@ import {
ServerOptions, ServerOptions,
} from 'vite' } from 'vite'
import express from 'express' import express from 'express'
import { hasOwn } from '@vue/shared' import { printHttpServerUrls } from 'vite'
import { parseManifestJson } from '@dcloudio/uni-cli-shared' import { parseManifestJson } from '@dcloudio/uni-cli-shared'
import { CliOptions } from '.' import { CliOptions } from '.'
import { addConfigFile, cleanOptions } from './utils' import { addConfigFile, cleanOptions } from './utils'
import { printHttpServerUrls } from './logger'
export async function createServer(options: CliOptions & ServerOptions) { export async function createServer(options: CliOptions & ServerOptions) {
const server = await createViteServer( const server = await createViteServer(
...@@ -35,7 +33,7 @@ export async function createServer(options: CliOptions & ServerOptions) { ...@@ -35,7 +33,7 @@ export async function createServer(options: CliOptions & ServerOptions) {
} }
) )
printHttpServerUrls(server.httpServer!, server.config) server.printUrls()
} }
export async function createSSRServer(options: CliOptions & ServerOptions) { export async function createSSRServer(options: CliOptions & ServerOptions) {
...@@ -61,7 +59,6 @@ export async function createSSRServer(options: CliOptions & ServerOptions) { ...@@ -61,7 +59,6 @@ export async function createSSRServer(options: CliOptions & ServerOptions) {
) )
// use vite's connect instance as middleware // use vite's connect instance as middleware
app.use(vite.middlewares) app.use(vite.middlewares)
app.use('*', async (req, res) => { app.use('*', async (req, res) => {
try { try {
const { h5 } = parseManifestJson(process.env.UNI_INPUT_DIR) const { h5 } = parseManifestJson(process.env.UNI_INPUT_DIR)
...@@ -100,11 +97,7 @@ export async function createSSRServer(options: CliOptions & ServerOptions) { ...@@ -100,11 +97,7 @@ export async function createSSRServer(options: CliOptions & ServerOptions) {
const logger = createLogger(options.logLevel) const logger = createLogger(options.logLevel)
const serverOptions = vite.config.server || {} const serverOptions = vite.config.server || {}
const protocol = (
hasOwn(options, 'https') ? options.https : serverOptions.https
)
? 'https'
: 'http'
let port = options.port || serverOptions.port || 3000 let port = options.port || serverOptions.port || 3000
let hostname: string | undefined let hostname: string | undefined
if (options.host === 'localhost') { if (options.host === 'localhost') {
...@@ -118,35 +111,7 @@ export async function createSSRServer(options: CliOptions & ServerOptions) { ...@@ -118,35 +111,7 @@ export async function createSSRServer(options: CliOptions & ServerOptions) {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const onSuccess = () => { const onSuccess = () => {
const interfaces = os.networkInterfaces() printHttpServerUrls(server, vite.config)
const locals: string[] = []
const networks: string[] = []
Object.keys(interfaces).forEach((key) =>
(interfaces[key] || [])
.filter((details) => details.family === 'IPv4')
.forEach((detail) => {
if (detail.address.includes('127.0.0.1')) {
locals.push(detail.address)
} else {
networks.push(detail.address)
}
})
)
locals.forEach((host) => {
const url = `${protocol}://${host}:${chalk.bold(port)}${
vite.config.base
}`
logger.info(` - Local: ${chalk.cyan(url)}`)
})
const networksLen = networks.length - 1
networks.forEach((host, index) => {
const url = `${protocol}://${host}:${chalk.bold(port)}${
vite.config.base
}`
logger.info(
` ${index === networksLen ? '-' : '>'} Network: ${chalk.cyan(url)}`
)
})
resolve(server) resolve(server)
} }
const onError = (e: Error & { code?: string }) => { const onError = (e: Error & { code?: string }) => {
......
...@@ -2770,7 +2770,7 @@ ...@@ -2770,7 +2770,7 @@
html-tags "^3.1.0" html-tags "^3.1.0"
svg-tags "^1.0.0" svg-tags "^1.0.0"
"@vue/compiler-core@3.2.20": "@vue/compiler-core@3.2.20", "@vue/compiler-core@^3.2.20":
version "3.2.20" version "3.2.20"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.20.tgz#af5a3c5237818835b0d0be837eb5885a8d21c160" resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.20.tgz#af5a3c5237818835b0d0be837eb5885a8d21c160"
integrity sha512-vcEXlKXoPwBXFP5aUTHN9GTZaDfwCofa9Yu9bbW2C5O/QSa9Esdt7OG4+0RRd3EHEMxUvEdj4RZrd/KpQeiJbA== integrity sha512-vcEXlKXoPwBXFP5aUTHN9GTZaDfwCofa9Yu9bbW2C5O/QSa9Esdt7OG4+0RRd3EHEMxUvEdj4RZrd/KpQeiJbA==
...@@ -10229,7 +10229,7 @@ verror@1.10.0: ...@@ -10229,7 +10229,7 @@ verror@1.10.0:
core-util-is "1.0.2" core-util-is "1.0.2"
extsprintf "^1.2.0" extsprintf "^1.2.0"
vite@^2.6.3: vite@^2.6.5:
version "2.6.5" version "2.6.5"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.5.tgz#c4d25972e2f7371e682da86828722ddf5126f3d1" resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.5.tgz#c4d25972e2f7371e682da86828722ddf5126f3d1"
integrity sha512-vavXMChDUb4Oh4YunrK9BrH5Ox74cu0eOp0VuyI/iqFz1FqbWD72So2c9I87lLL2n0+6tFPV5ijow60KrtxuZg== integrity sha512-vavXMChDUb4Oh4YunrK9BrH5Ox74cu0eOp0VuyI/iqFz1FqbWD72So2c9I87lLL2n0+6tFPV5ijow60KrtxuZg==
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册