forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
65 lines (62 loc) · 1.47 KB
/
postcss.config.js
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
const postcssImport = require('postcss-import');
const tailwindCss = require('tailwindcss');
const autoprefixer = require('autoprefixer')({
browsers: ['last 2 versions']
});
// 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 = require('@fullhuman/postcss-purgecss')({
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);
}
})
module.exports = {
plugins: [
postcssImport,
tailwindCss,
autoprefixer,
...(process.env.HUGO_ENVIRONMENT === 'production' ? [purgecss] : [])
]
}