Skip to content

Commit 6ae0615

Browse files
authoredAug 6, 2024··
fix(build): windows platform build output path error (#17818)
1 parent cf2f90d commit 6ae0615

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
 

‎packages/vite/src/node/plugins/css.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
594594

595595
const toRelative = (filename: string) => {
596596
// relative base + extracted CSS
597-
const relativePath = path.posix.relative(cssAssetDirname!, filename)
597+
const relativePath = normalizePath(
598+
path.relative(cssAssetDirname!, filename),
599+
)
598600
return relativePath[0] === '.' ? relativePath : './' + relativePath
599601
}
600602

@@ -615,9 +617,8 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
615617
})
616618
// resolve public URL from CSS paths
617619
if (encodedPublicUrls) {
618-
const relativePathToPublicFromCSS = path.posix.relative(
619-
cssAssetDirname!,
620-
'',
620+
const relativePathToPublicFromCSS = normalizePath(
621+
path.relative(cssAssetDirname!, ''),
621622
)
622623
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
623624
const publicUrl = publicAssetUrlMap.get(hash)!.slice(1)

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
330330
async transform(html, id) {
331331
if (id.endsWith('.html')) {
332332
id = normalizePath(id)
333-
const relativeUrlPath = path.posix.relative(config.root, id)
333+
const relativeUrlPath = normalizePath(path.relative(config.root, id))
334334
const publicPath = `/${relativeUrlPath}`
335335
const publicBase = getBaseInHTML(relativeUrlPath, config)
336336

@@ -776,7 +776,9 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
776776
}
777777

778778
for (const [normalizedId, html] of processedHtml) {
779-
const relativeUrlPath = path.posix.relative(config.root, normalizedId)
779+
const relativeUrlPath = normalizePath(
780+
path.relative(config.root, normalizedId),
781+
)
780782
const assetsBase = getBaseInHTML(relativeUrlPath, config)
781783
const toOutputFilePath = (
782784
filename: string,

0 commit comments

Comments
 (0)
Please sign in to comment.