Skip to content

Commit cc8800a

Browse files
authored
fix(build): build project path error (#9793)
1 parent c3f6731 commit cc8800a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • packages/vite/src/node/plugins

packages/vite/src/node/plugins/html.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {
1919
isDataUrl,
2020
isExternalUrl,
2121
normalizePath,
22-
processSrcSet,
23-
slash
22+
processSrcSet
2423
} from '../utils'
2524
import type { ResolvedConfig } from '../config'
2625
import { toOutputFilePathInHtml } from '../build'
@@ -297,7 +296,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
297296

298297
async transform(html, id) {
299298
if (id.endsWith('.html')) {
300-
const relativeUrlPath = slash(path.relative(config.root, id))
299+
const relativeUrlPath = path.posix.relative(
300+
config.root,
301+
normalizePath(id)
302+
)
301303
const publicPath = `/${relativeUrlPath}`
302304
const publicBase = getBaseInHTML(relativeUrlPath, config)
303305

@@ -669,7 +671,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
669671
}
670672

671673
for (const [id, html] of processedHtml) {
672-
const relativeUrlPath = path.posix.relative(config.root, id)
674+
const relativeUrlPath = path.posix.relative(
675+
config.root,
676+
normalizePath(id)
677+
)
673678
const assetsBase = getBaseInHTML(relativeUrlPath, config)
674679
const toOutputFilePath = (
675680
filename: string,

0 commit comments

Comments
 (0)