Skip to content

Commit

Permalink
Revert "feat(css): build assets with the entry name when it is an ent…
Browse files Browse the repository at this point in the history
…ry point (#11578)"

This reverts commit fd9a2cc.
  • Loading branch information
patak-dev committed Nov 10, 2023
1 parent 9a57916 commit fe09296
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 17 deletions.
10 changes: 4 additions & 6 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
pureCssChunks.add(chunk)
}
if (opts.format === 'es' || opts.format === 'cjs') {
const isEntry = chunk.isEntry && isPureCssChunk
const cssAssetName = normalizePath(
!isEntry && chunk.facadeModuleId
? path.relative(config.root, chunk.facadeModuleId)
: chunk.name,
)
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')
Expand Down Expand Up @@ -644,6 +641,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
source: chunkCSS,
})
const originalName = isPreProcessor(lang) ? cssAssetName : cssFileName
const isEntry = chunk.isEntry && isPureCssChunk
generatedAssets
.get(config)!
.set(referenceId, { originalName, isEntry })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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['../dynamic/foo.css'] // '\\' should not be used even on windows
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 @@ -48,9 +48,6 @@ describe.runIf(isBuild)('build', () => {
expect(imgAssetEntry?.file).not.toBeUndefined()
expect(imgAssetEntry?.isEntry).toBeUndefined()
expect(dirFooAssetEntry).not.toBeUndefined()
// use the entry name
expect(manifest['bar.css']).not.toBeUndefined()
expect(manifest['foo.css']).toBeUndefined()
})
})

Expand Down
2 changes: 1 addition & 1 deletion playground/backend-integration/dir/foo.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.entry-name-foo {
.windows-path-foo {
color: blue;
}
3 changes: 0 additions & 3 deletions playground/backend-integration/frontend/dynamic/foo.css

This file was deleted.

1 change: 0 additions & 1 deletion playground/backend-integration/frontend/dynamic/foo.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'vite/modulepreload-polyfill'
import('../dynamic/foo') // should be dynamic import to split chunks

export const colorClass = 'text-black'

Expand Down
2 changes: 1 addition & 1 deletion playground/backend-integration/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function BackendIntegrationExample() {
.map((filename) => [path.relative(root, filename), filename])

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

return {
build: {
Expand Down

0 comments on commit fe09296

Please sign in to comment.