diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 72ac5821348f9e..f4c4cf2845733e 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -552,8 +552,6 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const cssAssetName = chunk.facadeModuleId ? normalizePath(path.relative(config.root, chunk.facadeModuleId)) : chunk.name - - const lang = path.extname(cssAssetName).slice(1) const cssFileName = ensureFileExt(cssAssetName, '.css') chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName) @@ -565,7 +563,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { type: 'asset', source: chunkCSS, }) - const originalName = isPreProcessor(lang) ? cssAssetName : cssFileName + const originalName = isCSSRequest(cssAssetName) + ? cssAssetName + : cssFileName const isEntry = chunk.isEntry && isPureCssChunk generatedAssets .get(config)! diff --git a/playground/backend-integration/__tests__/backend-integration.spec.ts b/playground/backend-integration/__tests__/backend-integration.spec.ts index 8d067f0616775d..19fd1f1859e000 100644 --- a/playground/backend-integration/__tests__/backend-integration.spec.ts +++ b/playground/backend-integration/__tests__/backend-integration.spec.ts @@ -36,6 +36,7 @@ describe.runIf(isBuild)('build', () => { const htmlEntry = manifest['index.html'] const cssAssetEntry = manifest['global.css'] const scssAssetEntry = manifest['nested/blue.scss'] + const pcssAssetEntry = manifest['nested/red.pcss'] 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) @@ -45,6 +46,10 @@ describe.runIf(isBuild)('build', () => { expect(scssAssetEntry?.file).not.toBeUndefined() expect(scssAssetEntry?.src).toEqual('nested/blue.scss') expect(scssAssetEntry?.isEntry).toEqual(true) + expect(pcssAssetEntry?.file).not.toBeUndefined() + expect(pcssAssetEntry?.src).toEqual('nested/red.pcss') + expect(pcssAssetEntry?.isEntry).toEqual(true) + expect(pcssAssetEntry?.file).not.toBeUndefined() expect(imgAssetEntry?.file).not.toBeUndefined() expect(imgAssetEntry?.isEntry).toBeUndefined() expect(dirFooAssetEntry).not.toBeUndefined() diff --git a/playground/backend-integration/frontend/entrypoints/nested/red.pcss b/playground/backend-integration/frontend/entrypoints/nested/red.pcss new file mode 100644 index 00000000000000..bf4338cfa57fc5 --- /dev/null +++ b/playground/backend-integration/frontend/entrypoints/nested/red.pcss @@ -0,0 +1,3 @@ +.text-primary { + color: red; +}