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): windows platform build output path error #17818

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {

const toRelative = (filename: string) => {
// relative base + extracted CSS
const relativePath = path.posix.relative(cssAssetDirname!, filename)
const relativePath = normalizePath(
path.relative(cssAssetDirname!, filename),
)
return relativePath[0] === '.' ? relativePath : './' + relativePath
}

Expand All @@ -615,9 +617,8 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
})
// resolve public URL from CSS paths
if (encodedPublicUrls) {
const relativePathToPublicFromCSS = path.posix.relative(
cssAssetDirname!,
'',
const relativePathToPublicFromCSS = normalizePath(
path.relative(cssAssetDirname!, ''),
)
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
const publicUrl = publicAssetUrlMap.get(hash)!.slice(1)
Expand Down
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
async transform(html, id) {
if (id.endsWith('.html')) {
id = normalizePath(id)
const relativeUrlPath = path.posix.relative(config.root, id)
const relativeUrlPath = normalizePath(path.relative(config.root, id))
btea marked this conversation as resolved.
Show resolved Hide resolved
const publicPath = `/${relativeUrlPath}`
const publicBase = getBaseInHTML(relativeUrlPath, config)

Expand Down Expand Up @@ -776,7 +776,9 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
}

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