-
Notifications
You must be signed in to change notification settings - Fork 50
/
postcss.config.js
39 lines (38 loc) · 1.16 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
const path = require("path");
module.exports = () => ({
plugins: [
require("postcss-import")({
path: [
// Check for imports in <theme-dir>/css/assets
// TODO use Hugo's built-in inlineImports?
path.posix.join(__dirname, "assets", "css"),
],
}),
require("postcss-url")([
{
filter: "**/typeface-*/files/*",
url: (asset) => {
// Construct font path relative to <publish-dir>/css/bundle.css
// Fonts must be mounted into static/ dir
return path.posix.join("/", "fonts", path.basename(asset.pathname));
},
},
]),
require("postcss-nesting"),
require("postcss-custom-media"),
...(process.env.HUGO_ENVIRONMENT === "production"
? [
require("postcss-preset-env"),
require("cssnano"),
require("@fullhuman/postcss-purgecss")({
content: ["./hugo_stats.json"],
defaultExtractor: (content) => {
let els = JSON.parse(content).htmlElements;
return els.tags.concat(els.classes, els.ids);
},
safelist: ["data-theme"],
}),
]
: []),
],
});