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: cachedTransformMiddleware for direct css requests #15919

Merged

Conversation

patak-dev
Copy link
Member

Description

Fixes ttps://github.com/danielroe/css-flash-repro

The check we added in #15586 to detect mixed etags between direct and imported CSS was wrong. See explanation here to understand the problem: https://github.com/vitejs/vite/pull/15586/files#r1453060051. The issue is that isDirectRequest doesn't work because the query isn't added until the transform middleware kicks in.

This PR fixes the issue by reverting back to the previous 304 scheme for direct CSS requests. Imported CSS and all JS files will still go through the optimized path.

If we move from ?direct to marking with ?import as we do with assets, we may be able to optimize direct CSS imports too.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Copy link

stackblitz bot commented Feb 15, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release feat: css feat: dev dev server labels Feb 15, 2024
@patak-dev
Copy link
Member Author

The backend-integration test that imports a CSS file and also linked it was failing if we only avoid the optimization for direct requests. So the PR now bails out of it for all CSS files.

@patak-dev patak-dev merged commit 5099028 into main Feb 15, 2024
15 checks passed
@patak-dev patak-dev deleted the fix/cached-transform-middleware-for-direct-css-requests branch February 15, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css feat: dev dev server p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants