Repository navigation
Expand file tree
/
Copy pathpurgecss.config.mjs
More file actions
145 lines (139 loc) · 3.67 KB
/
Copy pathpurgecss.config.mjs
File metadata and controls
145 lines (139 loc) · 3.67 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Breakpoint first segment for responsive utilities — keep in sync with
// assets/core/scss/tokens/_utility-config.scss ($tutor-responsive-breakpoints).
const tutorUtilityBreakpoints = ['xl', 'lg', 'md', 'sm'];
const tutorResponsiveUtilityPrefix = `(?:${tutorUtilityBreakpoints.join('|')})-`;
const tutorIconColorUtilitiesRegex =
/^tutor-icon-(idle|idle-inverse|hover|secondary|subdued|brand|brand-hover|brand-secondary|success-primary|success-secondary|critical|critical-hover|warning|warning-secondary|caution|exception1|exception2|exception4|exception5|disabled)$/;
// Prefixes after `tutor-` (or after `tutor-{bp}-`) from assets/core/scss/utilities.
// Used by PurgeCSS so real utilities are not treated as component safelist entries.
const utilityPrefixes = [
'm[trblxy]?',
'p[trblxy]?',
'p[1-3]',
'w',
'h',
'min-w',
'min-h',
'max-w',
'max-h',
'bg',
'text',
'surface',
'icon',
'actions',
'shadow',
'opacity',
'border',
'rounded',
'block',
'inline',
'flex',
'grid',
'hidden',
'justify',
'items',
'content',
'self',
'gap',
'gap-x',
'gap-y',
'col',
'static',
'fixed',
'absolute',
'relative',
'sticky',
'top',
'bottom',
'left',
'right',
'inset',
'z',
'overflow',
'float',
'ratio',
'h[1-5]',
'medium',
'small',
'tiny',
'font',
'underline',
'line-through',
'no-underline',
'uppercase',
'lowercase',
'capitalize',
'normal-case',
'truncate',
'whitespace',
'break',
'list',
'hover',
'focus',
'transition',
'duration',
'delay',
'animate',
'origin',
'scale',
'rotate',
'translate',
'skew',
'transform',
'backface',
];
export const tutorComponentsRegex = new RegExp(
`^tutor-(?!(${tutorResponsiveUtilityPrefix})?(${utilityPrefixes.join('|')})(-|$))`,
);
export const purgecssContent = [
// Tutor LMS paths
path.resolve(__dirname, './components/**/*.php'),
path.resolve(__dirname, './templates/**/*.php'),
path.resolve(__dirname, './models/**/*.php'),
path.resolve(__dirname, './views/**/*.php'),
path.resolve(__dirname, './classes/**/*.php'),
path.resolve(__dirname, './assets/src/js/**/*.{js,ts,jsx,tsx}'),
path.resolve(__dirname, './assets/core/ts/**/*.{ts,tsx}'),
path.resolve(__dirname, './includes/**/*.php'),
path.resolve(__dirname, './ecommerce/**/*.php'),
path.resolve(__dirname, './tutor.php'),
// Third Party Scripts
path.resolve(__dirname, './node_modules/vanilla-calendar-pro/**/*.js'),
// Tutor LMS Pro paths
path.resolve(__dirname, '../tutor-pro/templates/**/*.php'),
path.resolve(__dirname, '../tutor-pro/classes/**/*.php'),
path.resolve(__dirname, '../tutor-pro/views/**/*.php'),
path.resolve(__dirname, '../tutor-pro/assets/src/js/**/*.{js,ts,jsx,tsx}'),
path.resolve(__dirname, '../tutor-pro/includes/**/*.php'),
path.resolve(__dirname, '../tutor-pro/addons/**/*.php'),
path.resolve(__dirname, '../tutor-pro/addons/**/*.{js,ts,jsx,tsx}'),
path.resolve(__dirname, '../tutor-pro/ecommerce/**/*.php'),
path.resolve(__dirname, '../tutor-pro/gift-course/**/*.php'),
path.resolve(__dirname, '../tutor-pro/tutor-pro.php'),
];
export const purgecssSafelist = {
standard: [
/^is-/,
/^has-/,
/^show-/,
/^tutor-theme-/,
/^vc-/,
/^wp-editor-/,
/^mce-/,
/^quicktags-/,
/^arrow-/,
tutorIconColorUtilitiesRegex,
tutorComponentsRegex,
/^tutor-skeleton/,
'active',
'disabled',
'failed',
'passed',
'pending',
],
deep: [/^vc-/, /^tutor-vc-/, /^tutor-range-calendar/],
greedy: [/data-vc/, /data-active/, /data-tutor-theme/, /data-tutor-contrast/],
};