File tree Expand file tree Collapse file tree 1 file changed +1
-39
lines changed Expand file tree Collapse file tree 1 file changed +1
-39
lines changed Original file line number Diff line number Diff line change 11import { spawn } from 'child_process'
2- import type { AddressInfo } from 'net'
32import {
43 type Plugin ,
54 type ViteDevServer ,
@@ -14,46 +13,9 @@ import {
1413 resolveRuntime ,
1514 resolveBuildConfig ,
1615 checkPkgMain ,
16+ resolveEnv ,
1717} from './config'
1818
19- export const loopbackHosts = new Set ( [
20- 'localhost' ,
21- '127.0.0.1' ,
22- '::1' ,
23- '0000:0000:0000:0000:0000:0000:0000:0001'
24- ] )
25-
26- export const wildcardHosts = new Set ( [
27- '0.0.0.0' ,
28- '::' ,
29- '0000:0000:0000:0000:0000:0000:0000:0000'
30- ] )
31-
32- function resolveHostname ( hostname : string ) {
33- return loopbackHosts . has ( hostname ) || wildcardHosts . has ( hostname ) ? 'localhost' : hostname
34- }
35-
36- function resolveEnv ( server : ViteDevServer ) {
37- const addressInfo = server . httpServer . address ( )
38- const isAddressInfo = ( x : any ) : x is AddressInfo => x ?. address
39-
40- if ( isAddressInfo ( addressInfo ) ) {
41- const { address, port } = addressInfo
42- const host = resolveHostname ( address )
43-
44- const options = server . config . server
45- const protocol = options . https ? 'https' : 'http'
46- const devBase = server . config . base
47-
48- const path = typeof options . open === 'string' ? options . open : devBase
49- const url = path . startsWith ( 'http' )
50- ? path
51- : `${ protocol } ://${ host } :${ port } ${ path } `
52-
53- return { url, host, port }
54- }
55- }
56-
5719/**
5820 * Custom start plugin
5921 */
You can’t perform that action at this time.
0 commit comments