Skip to content
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

fix: better support for external URL as config.base #4274

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/clientInjections.ts
Expand Up @@ -2,7 +2,7 @@ import path from 'path'
import type { Plugin } from '../plugin'
import type { ResolvedConfig } from '../config'
import { CLIENT_ENTRY, ENV_ENTRY } from '../constants'
import { isObject, normalizePath } from '../utils'
import { isExternalUrl, isObject, normalizePath } from '../utils'

// ids in transform are normalized to unix style
const normalizedClientEntry = normalizePath(CLIENT_ENTRY)
Expand Down Expand Up @@ -34,9 +34,9 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
}
let hmrBase = config.base
if (options.path) {
hmrBase = path.posix.join(hmrBase, options.path)
hmrBase = hmrBase + options.path
}
if (hmrBase !== '/') {
if (hmrBase !== '/' && !isExternalUrl(hmrBase)) {
port = path.posix.normalize(`${port}${hmrBase}`)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/middlewares/indexHtml.ts
Expand Up @@ -237,7 +237,7 @@ const devHtmlHook: IndexHtmlTransformHook = async (
tag: 'script',
attrs: {
type: 'module',
src: path.posix.join(base, CLIENT_PUBLIC_PATH)
src: base + CLIENT_PUBLIC_PATH.slice(1)
},
injectTo: 'head-prepend'
}
Expand Down