Skip to content

Commit

Permalink
fix: avoid --open optimization if preTransformRequests is disabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Oct 17, 2023
1 parent 4496ae7 commit d4f62e4
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,27 +451,30 @@ export async function _createServer(
// We know the url that the browser would be opened to, so we can
// start the request while we are awaiting the browser. This will
// start the crawling of static imports ~500ms before.
setTimeout(() => {
httpGet(
path,
{
headers: {
// Allow the history middleware to redirect to /index.html
Accept: 'text/html',
// preTransformRequests needs to be enabled for this optimization.
if (server.config.server.preTransformRequests) {
setTimeout(() => {
httpGet(
path,
{
headers: {
// Allow the history middleware to redirect to /index.html
Accept: 'text/html',
},
},
},
(res) => {
res.on('end', () => {
// Ignore response, scripts discovered while processing the entry
// will be preprocessed (server.config.server.preTransformRequests)
(res) => {
res.on('end', () => {
// Ignore response, scripts discovered while processing the entry
// will be preprocessed (server.config.server.preTransformRequests)
})
},
)
.on('error', () => {
// Ignore errors
})
},
)
.on('error', () => {
// Ignore errors
})
.end()
}, 0)
.end()
}, 0)
}

_openBrowser(path, true, server.config.logger)
} else {
Expand Down

0 comments on commit d4f62e4

Please sign in to comment.