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(build): build project path error #9793

Merged
merged 4 commits into from Aug 27, 2022
Merged
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
13 changes: 9 additions & 4 deletions packages/vite/src/node/plugins/html.ts
Expand Up @@ -26,8 +26,7 @@ import {
isDataUrl,
isExternalUrl,
normalizePath,
processSrcSet,
slash
processSrcSet
} from '../utils'
import type { ResolvedConfig } from '../config'
import { toOutputFilePathInHtml } from '../build'
Expand Down Expand Up @@ -246,7 +245,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {

async transform(html, id) {
if (id.endsWith('.html')) {
const relativeUrlPath = slash(path.relative(config.root, id))
const relativeUrlPath = path.posix.relative(
config.root,
normalizePath(id)
)
const publicPath = `/${relativeUrlPath}`
const publicBase = getBaseInHTML(relativeUrlPath, config)

Expand Down Expand Up @@ -620,7 +622,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
}

for (const [id, html] of processedHtml) {
const relativeUrlPath = path.posix.relative(config.root, id)
const relativeUrlPath = path.posix.relative(
config.root,
normalizePath(id)
)
const assetsBase = getBaseInHTML(relativeUrlPath, config)
const toOutputFilePath = (
filename: string,
Expand Down