astro-purgecss 4.1.1 → 4.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 +15 -14
- package/dist/index.mjs +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,9 +85,9 @@ export default defineConfig({
|
|
|
85
85
|
// Example using a taiwindcss compatible class extractor
|
|
86
86
|
extractor: (content) =>
|
|
87
87
|
content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
|
|
88
|
-
extensions: [
|
|
89
|
-
}
|
|
90
|
-
]
|
|
88
|
+
extensions: ['astro', 'html']
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
91
|
})
|
|
92
92
|
]
|
|
93
93
|
});
|
|
@@ -111,11 +111,11 @@ export type PurgeCSSOptions = {
|
|
|
111
111
|
safelist?: UserDefinedSafelist; // indicates which selectors are safe to leave in the final CSS
|
|
112
112
|
blocklist?: StringRegExpArray; // blocks the CSS selectors from appearing in the final output CSS
|
|
113
113
|
content?: Array<string | RawContent>;
|
|
114
|
-
extractors?:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
extractors?: // provides custom functions to extract CSS classes in specific ways (eg. when using tailwind.css)
|
|
115
|
+
Array<{
|
|
116
|
+
extractor: (content: string) => string[]; // matched css classes
|
|
117
|
+
extensions: string[]; // file extensions for which this extractor is to be used
|
|
118
|
+
}>;
|
|
119
119
|
};
|
|
120
120
|
```
|
|
121
121
|
|
|
@@ -129,8 +129,8 @@ We have also setup an example repository available here: [example-purgecss](../.
|
|
|
129
129
|
|
|
130
130
|
- 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.
|
|
131
131
|
|
|
132
|
-
|
|
133
132
|
- If you are using Astro view transitions, use the following options so that purgecss keeps the corresponding animations:
|
|
133
|
+
|
|
134
134
|
```diff
|
|
135
135
|
export default defineConfig({
|
|
136
136
|
integrations: [
|
|
@@ -145,6 +145,7 @@ export default defineConfig({
|
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
- 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). You may also need a custom class extractor compatible with arbitrary and container based `tailwind.css` classes. For example:
|
|
148
|
+
|
|
148
149
|
```js
|
|
149
150
|
export default defineConfig({
|
|
150
151
|
integrations: [
|
|
@@ -153,11 +154,11 @@ export default defineConfig({
|
|
|
153
154
|
{
|
|
154
155
|
extractor: (content) =>
|
|
155
156
|
content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [],
|
|
156
|
-
extensions: [
|
|
157
|
-
}
|
|
158
|
-
]
|
|
159
|
-
})
|
|
160
|
-
]
|
|
157
|
+
extensions: ['astro', 'html']
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
})
|
|
161
|
+
]
|
|
161
162
|
});
|
|
162
163
|
```
|
|
163
164
|
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,7 @@ import { PurgeCSS } from "purgecss";
|
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
function handleWindowsPath(outputPath) {
|
|
5
|
-
if (process.platform !== "win32")
|
|
6
|
-
return outputPath;
|
|
5
|
+
if (process.platform !== "win32") return outputPath;
|
|
7
6
|
if (outputPath.endsWith("\\")) {
|
|
8
7
|
outputPath = outputPath.substring(0, outputPath.length - 1);
|
|
9
8
|
}
|