Skip to content

Commit 13e6450

Browse files
timacdonaldsapphi-red
andauthoredJul 25, 2022
fix: normalise css paths in manifest on windows (fixes #9295) (#9353)
Co-authored-by: sapphi-red <green@sapphi.red>
1 parent 4215d46 commit 13e6450

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed
 

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
519519
}
520520

521521
function ensureFileExt(name: string, ext: string) {
522-
return path.format({ ...path.parse(name), base: undefined, ext })
522+
return normalizePath(
523+
path.format({ ...path.parse(name), base: undefined, ext })
524+
)
523525
}
524526

525527
if (config.build.cssCodeSplit) {

‎playground/backend-integration/__tests__/backend-integration.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe.runIf(isBuild)('build', () => {
3535
const cssAssetEntry = manifest['global.css']
3636
const scssAssetEntry = manifest['nested/blue.scss']
3737
const imgAssetEntry = manifest['../images/logo.png']
38+
const dirFooAssetEntry = manifest['../../dir/foo.css'] // '\\' should not be used even on windows
3839
expect(htmlEntry.css.length).toEqual(1)
3940
expect(htmlEntry.assets.length).toEqual(1)
4041
expect(cssAssetEntry?.file).not.toBeUndefined()
@@ -44,6 +45,7 @@ describe.runIf(isBuild)('build', () => {
4445
expect(scssAssetEntry?.isEntry).toEqual(true)
4546
expect(imgAssetEntry?.file).not.toBeUndefined()
4647
expect(imgAssetEntry?.isEntry).toBeUndefined()
48+
expect(dirFooAssetEntry).not.toBeUndefined()
4749
})
4850
})
4951

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.windows-path-foo {
2+
color: blue;
3+
}

‎playground/backend-integration/vite.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function BackendIntegrationExample() {
1919
.map((filename) => [path.relative(root, filename), filename])
2020

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

2324
return {
2425
build: {

0 commit comments

Comments
 (0)
Please sign in to comment.