orbit icon indicating copy to clipboard operation
orbit copied to clipboard

[astro-purgecss] No way to config Astro SSR

Open khromov opened this issue 1 month ago • 1 comments

Describe the bug In the README it says:

If you are using Astro SSR in your project, you must add your astro and framework sources files into the content option (see in the example).

But there is no example, and without it CSS files aren't working at all when building an app using Astro SSR. What is content supposed to be set to?

khromov avatar Oct 10 '25 16:10 khromov

I admit the SSR setup for this package is a bit rough, it’s not well-documented.

Technically, you need to tell PurgeCSS which files to scan so it can detect which classes are actually used and which ones to remove.

export default defineConfig({
  integrations: [
    purgecss({
      content: ['./src/**/*.astro']
    })
  ]
});

Caveats

  • ✅ Recommended: Use external stylesheet files (.css)
  • ⚠️ Less Effective: Inline styles in astro files

mhdcodes avatar Oct 11 '25 21:10 mhdcodes