-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathpostcss.config.js
More file actions
46 lines (45 loc) · 1.38 KB
/
postcss.config.js
File metadata and controls
46 lines (45 loc) · 1.38 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
import path from "path";
import postcssImport from "postcss-import";
import postcssUrl from "postcss-url";
import postcssNesting from "postcss-nesting";
import postcssCustomMedia from "postcss-custom-media";
import postcssPresetEnv from "postcss-preset-env";
import cssnano from "cssnano";
import { purgeCSSPlugin } from "@fullhuman/postcss-purgecss";
export default {
plugins: [
postcssImport({
path: [
// Check for imports in <theme-dir>/css/assets
// TODO use Hugo's built-in inlineImports?
path.posix.join(import.meta.dirname, "assets", "css"),
],
}),
postcssUrl([
{
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));
},
},
]),
postcssNesting,
postcssCustomMedia,
...(process.env.HUGO_ENVIRONMENT === "production"
? [
postcssPresetEnv,
cssnano,
purgeCSSPlugin({
content: ["./hugo_stats.json"],
defaultExtractor: (content) => {
let els = JSON.parse(content).htmlElements;
return els.tags.concat(els.classes, els.ids);
},
safelist: ["data-theme"],
}),
]
: []),
],
};