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: normalise css paths in manifest on windows (fixes #9295) #9353

Merged
merged 4 commits into from Jul 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -519,7 +519,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
}

function ensureFileExt(name: string, ext: string) {
return path.format({ ...path.parse(name), base: undefined, ext })
return normalizePath(
path.format({ ...path.parse(name), base: undefined, ext })
)
}

if (config.build.cssCodeSplit) {
Expand Down
Expand Up @@ -35,6 +35,7 @@ describe.runIf(isBuild)('build', () => {
const cssAssetEntry = manifest['global.css']
const scssAssetEntry = manifest['nested/blue.scss']
const imgAssetEntry = manifest['../images/logo.png']
const dirFooAssetEntry = manifest['../../dir/foo.css'] // '\\' should not be used even on windows
expect(htmlEntry.css.length).toEqual(1)
expect(htmlEntry.assets.length).toEqual(1)
expect(cssAssetEntry?.file).not.toBeUndefined()
Expand All @@ -44,6 +45,7 @@ describe.runIf(isBuild)('build', () => {
expect(scssAssetEntry?.isEntry).toEqual(true)
expect(imgAssetEntry?.file).not.toBeUndefined()
expect(imgAssetEntry?.isEntry).toBeUndefined()
expect(dirFooAssetEntry).not.toBeUndefined()
})
})

Expand Down
3 changes: 3 additions & 0 deletions playground/backend-integration/dir/foo.css
@@ -0,0 +1,3 @@
.windows-path-foo {
color: blue;
}
1 change: 1 addition & 0 deletions playground/backend-integration/vite.config.js
Expand Up @@ -19,6 +19,7 @@ function BackendIntegrationExample() {
.map((filename) => [path.relative(root, filename), filename])

entrypoints.push(['tailwindcss-colors', 'tailwindcss/colors.js'])
entrypoints.push(['foo.css', path.resolve(__dirname, './dir/foo.css')])

return {
build: {
Expand Down