astro-purgecss 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,12 +67,19 @@ export default defineConfig({
|
|
|
67
67
|
fontFace: true,
|
|
68
68
|
keyframes: true,
|
|
69
69
|
safelist: ['random', 'yep', 'button', /^nav-/],
|
|
70
|
-
blocklist: ['usedClass', /^nav-/]
|
|
70
|
+
blocklist: ['usedClass', /^nav-/],
|
|
71
|
+
content: [
|
|
72
|
+
process.cwd() + '/src/**/*.{astro,vue}', // Watching astro and vue sources (for SSR, read the note below)
|
|
73
|
+
],
|
|
71
74
|
})
|
|
72
75
|
]
|
|
73
76
|
});
|
|
74
77
|
```
|
|
75
78
|
|
|
79
|
+
> **Note**
|
|
80
|
+
>
|
|
81
|
+
> 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). Otherwise, as the package only look at the final build sent to the client, with SSR, some pages may not be included and may break your CSS.
|
|
82
|
+
|
|
76
83
|
### Available Options
|
|
77
84
|
|
|
78
85
|
Here is a list of options, that are allowed to be passed in the config:
|
|
@@ -86,6 +93,7 @@ export type PurgeCSSOptions = {
|
|
|
86
93
|
variables?: boolean; // removes any unused CSS variables if set to true
|
|
87
94
|
safelist?: UserDefinedSafelist; // indicates which selectors are safe to leave in the final CSS
|
|
88
95
|
blocklist?: StringRegExpArray; // blocks the CSS selectors from appearing in the final output CSS
|
|
96
|
+
content?: Array<string | RawContent>;
|
|
89
97
|
};
|
|
90
98
|
```
|
|
91
99
|
|
|
@@ -95,7 +103,7 @@ We have also setup an example repository available here: [example-purgecss](../.
|
|
|
95
103
|
|
|
96
104
|
### Caveats
|
|
97
105
|
|
|
98
|
-
-
|
|
106
|
+
- Some options are not allowed to be passed in your `astro.config.mjs` config file, to not interfere with the internals of this integration.
|
|
99
107
|
|
|
100
108
|
- If you are using `tailwind.css`, please read about purge limitations in this guide [writing-purgeable-html](https://v2.tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html)
|
|
101
109
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
|
-
import { StringRegExpArray, UserDefinedSafelist } from 'purgecss';
|
|
2
|
+
import { RawContent, StringRegExpArray, UserDefinedSafelist } from 'purgecss';
|
|
3
3
|
export type PurgeCSSOptions = {
|
|
4
4
|
fontFace?: boolean;
|
|
5
5
|
keyframes?: boolean;
|
|
@@ -8,5 +8,6 @@ export type PurgeCSSOptions = {
|
|
|
8
8
|
variables?: boolean;
|
|
9
9
|
safelist?: UserDefinedSafelist;
|
|
10
10
|
blocklist?: StringRegExpArray;
|
|
11
|
+
content?: Array<string | RawContent>;
|
|
11
12
|
};
|
|
12
13
|
export default function (options?: PurgeCSSOptions): AstroIntegration;
|
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,8 @@ function src_default(options = {}) {
|
|
|
20
20
|
...options,
|
|
21
21
|
content: [
|
|
22
22
|
`${outDir}/**/*.html`,
|
|
23
|
-
`${outDir}/**/*.js
|
|
23
|
+
`${outDir}/**/*.js`,
|
|
24
|
+
...options.content || []
|
|
24
25
|
],
|
|
25
26
|
css: [`${outDir}/**/*.css`],
|
|
26
27
|
defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || []
|
package/package.json
CHANGED