@@ -2,6 +2,7 @@ import { createServer, searchForWorkspaceRoot } from "vite";
2
2
import koa from "koa" ;
3
3
import http from "http" ;
4
4
import http2 from "http2" ;
5
+ import https from "https" ;
5
6
import c2k from "koa-connect" ;
6
7
import path from "path" ;
7
8
import getPort from "get-port" ;
@@ -102,8 +103,8 @@ const bundler = async (config, configFolder) => {
102
103
( vite . config . server . host === true
103
104
? "0.0.0.0"
104
105
: typeof vite . config . server . host === "string"
105
- ? vite . config . server . host
106
- : "localhost" ) ;
106
+ ? vite . config . server . host
107
+ : "localhost" ) ;
107
108
const serverUrl = `${ useHttps ? "https" : "http" } ://${ hostname } :${ port } ${
108
109
vite . config . base || ""
109
110
} `;
@@ -131,27 +132,33 @@ const bundler = async (config, configFolder) => {
131
132
} ;
132
133
133
134
if ( useHttps ) {
134
- http2
135
- . createSecureServer (
136
- {
137
- // Support HMR WS connection
138
- allowHTTP1 : true ,
139
- maxSessionMemory : 100 ,
140
- settings : {
141
- // Note: Chromium-based browser will initially allow 100 concurrent streams to be open
142
- // over a single HTTP/2 connection, unless HTTP/2 server advertises a different value,
143
- // in which case it will be capped at maximum of 256 concurrent streams. Hence pushing
144
- // to the limit while in development, in an attempt to maximize the dev performance by
145
- // minimizing the chances of the module requests queuing/stalling on the client-side.
146
- // @see https://source.chromium.org/chromium/chromium/src/+/4c44ff10bcbdb2d113dcc43c72f3f47a84a8dd45:net/spdy/spdy_session.cc;l=477-479
147
- maxConcurrentStreams : 256 ,
135
+ if ( config . disableHttp2 ) {
136
+ https
137
+ . createServer ( { ...vite . config . server . https } , app . callback ( ) )
138
+ . listen ( port , hostname , listenCallback ) ;
139
+ } else {
140
+ http2
141
+ . createSecureServer (
142
+ {
143
+ // Support HMR WS connection
144
+ allowHTTP1 : true ,
145
+ maxSessionMemory : 100 ,
146
+ settings : {
147
+ // Note: Chromium-based browser will initially allow 100 concurrent streams to be open
148
+ // over a single HTTP/2 connection, unless HTTP/2 server advertises a different value,
149
+ // in which case it will be capped at maximum of 256 concurrent streams. Hence pushing
150
+ // to the limit while in development, in an attempt to maximize the dev performance by
151
+ // minimizing the chances of the module requests queuing/stalling on the client-side.
152
+ // @see https://source.chromium.org/chromium/chromium/src/+/4c44ff10bcbdb2d113dcc43c72f3f47a84a8dd45:net/spdy/spdy_session.cc;l=477-479
153
+ maxConcurrentStreams : 256 ,
154
+ } ,
155
+ // @ts -ignore
156
+ ...vite . config . server . https ,
148
157
} ,
149
- // @ts -ignore
150
- ...vite . config . server . https ,
151
- } ,
152
- app . callback ( ) ,
153
- )
154
- . listen ( port , hostname , listenCallback ) ;
158
+ app . callback ( ) ,
159
+ )
160
+ . listen ( port , hostname , listenCallback ) ;
161
+ }
155
162
} else {
156
163
http . createServer ( app . callback ( ) ) . listen ( port , hostname , listenCallback ) ;
157
164
}
0 commit comments