Skip to content

Commit

Permalink
[astro-purgecss] add docs for handling inline styles (#605)
Browse files Browse the repository at this point in the history
* [astro-purgecss] Update docs

* fix typo

* docs(changeset): [astro-purgecss] add docs for handling inline styles
  • Loading branch information
mhdcodes authored Aug 24, 2024
1 parent f6801f1 commit 63b2e9d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-llamas-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro-purgecss': patch
---

[astro-purgecss] add docs for handling inline styles
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
dev@codiume.com.
<dev@codiume.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
12 changes: 10 additions & 2 deletions packages/astro-purgecss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ export default {

When you install this integration, things will be auto-wired for you. and all your generated css files should be purged from unused classes automagically.

However, there's one small caveat: By default, Astro inlines small CSS files as part of its [bundle control](https://docs.astro.build/en/guides/styling/#bundle-control). This means that the plugin won't be able to purge CSS rules from those inlined files. To prevent Astro from inlining CSS styles, you can set the `inlineStylesheets` option to `never` in your `astro.config.mjs` file:

```diff
export default defineConfig({
+ build: {
+ inlineStylesheets: 'never'
+ }
});
```

## 📖 Configuration

[PurgeCSS][purgecss] has a list of options that allow you to customize its behavior. And this Astro integration allow you to pass those options easily in your `astro.config.mjs` file:
Expand Down Expand Up @@ -127,8 +137,6 @@ We have also setup an example repository available here: [example-purgecss](../.

- Some options are not allowed to be passed in your `astro.config.mjs` config file, to not interfere with the internals of this integration.

- If you are using [inline styles](https://docs.astro.build/en/guides/styling/#scoped-styles), this plugin won't be able to purge those css rules, due to astro's way of handling scoped css rules.

- If you are using Astro view transitions, use the following options so that purgecss keeps the corresponding animations:

```diff
Expand Down

0 comments on commit 63b2e9d

Please sign in to comment.