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

Regression with CSS importing from MDX files #12635

Closed
1 task
smilosevic opened this issue Dec 4, 2024 · 1 comment · Fixed by vitejs/vite#18895
Closed
1 task

Regression with CSS importing from MDX files #12635

smilosevic opened this issue Dec 4, 2024 · 1 comment · Fixed by vitejs/vite#18895
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) ecosystem: upstream Upstream package has issue

Comments

@smilosevic
Copy link

Astro Info

Astro                    v5.0.2
Node                     v18.20.3
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I use mdx files do import CSS based on dynamic components from CMS.

After migrating to v5, it stopped working properly in dev mode. It works only on first page load after build. CSS is missing after refresh and won't appear until rebuild.

I nailed it down to combination of tailwind applying styles, and scanning every astro file:

// tailwind.config.js

export default {
    content: ['./src/**/*.astro'],
};
// astro.config.mjs

import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import tailwind from '@astrojs/tailwind';

// https://astro.build/config
export default defineConfig({
  integrations: [
    mdx(),
    tailwind({
      // applyBaseStyles: false,
    }),
  ],
});

If i disable scanning of all astro files or disable applyBaseStyles it works.

Also, i tried using new collections API, but the same thing is happening, so I just made example with minimum code

What's the expected result?

To apply styles imported from mdx on page refresh. Initially, page background is red from CSS code, and on refresh styles are not applied.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-jg5tdb

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 4, 2024
@bluwy bluwy added ecosystem: upstream Upstream package has issue - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Dec 5, 2024
@smilosevic
Copy link
Author

This is fixed with today's vite release: vite 6.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) ecosystem: upstream Upstream package has issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants