#css purging

7 messages · Page 1 of 1 (latest)

marsh trench
#

does astro v5 purges css in building per default?

mild wagonBOT
#

Hi @marsh trench. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The knowledge sources do not explicitly mention any built‑in CSS “purging” (tree‑shaking of unused selectors) being done by Astro v5 during build.

What Astro does by default is:

  • Bundle, split, and inline/externalize CSS based on size (inlineStylesheets + Vite’s assetsInlineLimit). [Production styling; inlineStyleSheets change]
  • Optimize CSS delivery (chunking, minification), but not remove unused selectors according to the docs we have.

If you want actual CSS purging, the integrations list shows community plugins like astro-purgecss-static and @zokki/astro-purgecss specifically for removing unused CSS from Astro static builds. [Integrations list]

So, based on the provided docs: no, Astro v5 does not purge unused CSS by default; you’d need an additional tool/integration for that.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@marsh trench Kapa.ai is still learning and improving, please let me know how I did by reacting below.

marsh trench
#

@mild wagon so to be clear, astro wont remove unused scss rules by default in build process?

mild wagonBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Based on the docs available, there is no mention that Astro’s build process removes unused CSS/SCSS rules by default.

What Astro does do automatically is:

But actual “purging” (removing unused selectors) is only referenced via community integrations like astro-purgecss-static and @zokki/astro-purgecss, which exist specifically to remove unused CSS from Astro static builds. [PurgeCSS integrations]

So, as far as the provided sources show: no, Astro will not remove unused SCSS/CSS rules by default during the build; you’d need an extra tool/integration for that.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: