Skip to content

Commit

Permalink
fix: normalise css paths in manifest on windows (fixes #9295) (#9353)
Browse files Browse the repository at this point in the history
Co-authored-by: sapphi-red <[email protected]>
  • Loading branch information
timacdonald and sapphi-red authored Jul 25, 2022
1 parent 4215d46 commit 13e6450
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.windows-path-foo {
color: blue;
}
1 change: 1 addition & 0 deletions playground/backend-integration/vite.config.js
Original file line number Diff line number Diff line change
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

0 comments on commit 13e6450

Please sign in to comment.