Skip to content

Commit 288ac6e

Browse files
authored
refactor(vite-plugin): fix redirect handling and improve error messages (#1782)
1 parent 567245f commit 288ac6e

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

packages/vite-plugin-tempest/src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ async function loadConfigurationFromTempestConsole(): Promise<TempestViteConfigu
5252
const { stdout } = await exec(`${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}`)
5353
const json = stdout.match(/\{.*\}/s)
5454

55-
return JSON.parse(json?.[0] as string)
55+
if (!json?.[0]) {
56+
throw new Error('Could not find valid JSON in Tempest console output')
57+
}
58+
59+
return JSON.parse(json[0])
5660
} catch (error) {
5761
console.error(
5862
`[vite-plugin-tempest] Could not load configuration from [${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}].`,

packages/vite-plugin-tempest/src/plugin.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export default function tempest(): Plugin {
193193
if (req.url === '/index.html') {
194194
res.writeHead(302, { Location: appUrl })
195195
res.end()
196+
return
196197
}
197198

198199
next()
@@ -325,10 +326,6 @@ function resolveEnvironmentServerConfig(env: Record<string, string>): {
325326
* Resolve the host name from the environment.
326327
*/
327328
function resolveHostFromEnv(env: Record<string, string>): string | undefined {
328-
if (env.VITE_DEV_SERVER_KEY) {
329-
return env.VITE_DEV_SERVER_KEY
330-
}
331-
332329
try {
333330
return new URL(env.BASE_URI).host
334331
} catch {

packages/vite/src/PrefetchConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct(
1313
public PrefetchStrategy $strategy = PrefetchStrategy::NONE,
1414

1515
/**
16-
* Number of assets to prefech concurrently when using the waterfall strategy.
16+
* Number of assets to prefetch concurrently when using the waterfall strategy.
1717
*/
1818
public int $concurrent = 3,
1919

0 commit comments

Comments
 (0)