-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathpostcss.config.js
More file actions
64 lines (61 loc) · 1.46 KB
/
postcss.config.js
File metadata and controls
64 lines (61 loc) · 1.46 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
import postcssImport from 'postcss-import';
import tailwindCss from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import purgecssPlugin from '@fullhuman/postcss-purgecss';
// These are classes for things that are applied by JS, and thus missed by Hugo.
// See assets/js/*.js for places where this happens.
const safeClasses = {
standard: [
"search-input",
"search-results-list",
"search-result",
"code-sample-filename",
"type",
// All Algolia-specific classes
/^ais-/,
/^aa-/,
/^DocSearch/,
// Search widgets (TODO: improve this by consolidating these into higher classes)
"block",
"border-gray-200",
"border-gray-300",
"border-r",
"border-t",
"font-medium",
"h-2",
"h-3",
"h-full",
"inline",
"leading-relaxed",
"mb-1",
"ml-1",
"mr-1",
"p-2",
"p-4",
"pl-2",
"py-4",
"text-gray-600",
"text-gray-800",
"text-md",
"text-sm",
"w-2",
"w-3",
]
};
const purgecss = purgecssPlugin({
content: ['./hugo_stats.json'],
safelist: safeClasses,
defaultExtractor: (content) => {
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
return broadMatches.concat(innerMatches);
}
});
export default {
plugins: [
postcssImport,
tailwindCss,
autoprefixer,
...(process.env.HUGO_ENVIRONMENT === 'production' ? [purgecss] : [])
]
}