-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpurgecss.config.js
More file actions
95 lines (78 loc) · 2.87 KB
/
purgecss.config.js
File metadata and controls
95 lines (78 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Created By: Claude Code (Claude Sonnet 4.5)
* Date: 2026-02-08T14:30:00-05:00
* Last Modified By: Claude Code (Claude Sonnet 4.6) | Last Modified: 2026-02-19T14:36:00-05:00
*/
module.exports = {
// Content files to scan for used CSS classes
// Note: using explicit paths (not themes/**/) to avoid the exampleSite symlink
// at themes/coreydaley-dev/exampleSite/themes/coreydaley-dev -> ../../ which
// causes infinite recursion with wildcard globs.
content: [
// Hugo templates
'themes/coreydaley-dev/layouts/**/*.html',
'layouts/**/*.html',
// Hugo content files
'content/**/*.md',
'content/**/*.html',
// Built site (for dynamically generated content)
'public/**/*.html',
// JavaScript files that might add classes
'themes/coreydaley-dev/static/**/*.js',
'themes/coreydaley-dev/assets/**/*.js',
'static/**/*.js',
],
// CSS files to purge
css: [
'themes/coreydaley-dev/assets/css/style.css',
],
// Output directory
output: 'themes/coreydaley-dev/static/css/',
// Safelist - classes to always keep
safelist: {
// Standard safelist for always-kept classes
standard: [
/^pagefind/, // Pagefind search classes
/^search-/, // Search-related classes
/^highlight/, // Code highlighting
/^chroma/, // Hugo's Chroma syntax highlighter
/^language-/, // Language-specific code blocks
/^token/, // Code tokens
/^data-pagefind/, // Pagefind data attributes
],
// Deep safelist - keeps class and all its children/descendants
deep: [
/^post-content/, // Post content and all children
/^code/, // Code blocks and children
/^pre/, // Pre-formatted text
],
// Greedy safelist - keeps class and modifiers
greedy: [
/^nav-/, // Navigation classes
/^header-/, // Header classes
/^footer-/, // Footer classes
/^sidebar-/, // Sidebar classes
/^taxonomy-/, // Taxonomy (tags/categories) classes
/^post-/, // Post-related classes
],
},
// Reject specific selectors
rejected: true,
// Include information about rejected selectors
rejectedCss: false,
// Options for extractors
defaultExtractor: content => {
// Extract classes from Hugo templates and content
// This regex matches class names in various contexts
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
// Also match Hugo template variables that might contain classes
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
return broadMatches.concat(innerMatches);
},
// Variables to keep (CSS custom properties)
variables: true,
// Keyframes to keep
keyframes: true,
// Font-face to keep
fontFace: true,
};