From cc8800a8e7613961144a567f4024b71f218224f8 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 27 Aug 2022 13:30:43 +0800 Subject: [PATCH] fix(build): build project path error (#9793) --- packages/vite/src/node/plugins/html.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index c0963f5f5f459f..eb20b2d0af205b 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -19,8 +19,7 @@ import { isDataUrl, isExternalUrl, normalizePath, - processSrcSet, - slash + processSrcSet } from '../utils' import type { ResolvedConfig } from '../config' import { toOutputFilePathInHtml } from '../build' @@ -297,7 +296,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) @@ -669,7 +671,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,