-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
41 lines (38 loc) · 933 Bytes
/
next.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
const withCss = require("@zeit/next-css");
const withPurgeCss = require("next-purgecss");
const tipsPages = require("./data.json").tips.reduce((prev, current) => {
return {
...prev,
[`/t/${current.slug}`]: {
page: `/t/[id]`,
query: { id: current.slug }
}
};
}, {});
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
}
}
// next.config.js
module.exports = withCss(
withPurgeCss({
exportPathMap() {
return {
"/": { page: "/" },
"t/index": { page: "/" },
...tipsPages
};
},
purgeCssEnabled: ({ dev, isServer }) => !dev && !isServer, // Only enable PurgeCSS for client-side production builds
purgeCss: {
whitelist: ["html", "body"],
extractors: [
{
extractor: TailwindExtractor,
extensions: ["html", "js", "css", "tsx"]
}
]
}
})
);