Skip to content

Include base in hotFile without modifying server.origin replacement #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ interface LaravelPlugin extends Plugin {
config: (config: UserConfig, env: ConfigEnv) => UserConfig
}

type DevServerUrl = `${'http'|'https'}://${string}:${number}${string}`
type DevServerUrl = `${'http'|'https'}://${string}:${number}`

let exitHandlersBound = false

Expand Down Expand Up @@ -204,7 +204,8 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
const isAddressInfo = (x: string|AddressInfo|null|undefined): x is AddressInfo => typeof x === 'object'
if (isAddressInfo(address)) {
viteDevServerUrl = userConfig.server?.origin ? userConfig.server.origin as DevServerUrl : resolveDevServerUrl(address, server.config, userConfig)
fs.writeFileSync(pluginConfig.hotFile, viteDevServerUrl)

fs.writeFileSync(pluginConfig.hotFile, `${viteDevServerUrl}${server.config.base.replace(/\/$/, '')}`)

setTimeout(() => {
server.config.logger.info(`\n ${colors.red(`${colors.bold('LARAVEL')} ${laravelVersion()}`)} ${colors.dim('plugin')} ${colors.bold(`v${pluginVersion()}`)}`)
Expand Down Expand Up @@ -431,9 +432,8 @@ function resolveDevServerUrl(address: AddressInfo, config: ResolvedConfig, userC

const configHmrClientPort = typeof config.server.hmr === 'object' ? config.server.hmr.clientPort : null
const port = configHmrClientPort ?? address.port
const base = config.base.replace(/\/$/, '')

return `${protocol}://${host}:${port}${base}`
return `${protocol}://${host}:${port}`
}

function isIpv6(address: AddressInfo): boolean {
Expand Down
Loading