This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
next.config.js
executable file
·57 lines (51 loc) · 1.54 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const path = require("path")
const withCSS = require("@zeit/next-css") // enable CSS + PostCSS
const withPurgeCSS = require("next-purgecss") // enable PurgeCSS
const withPlugins = require("next-compose-plugins")
const defaultGetLocalIdent = require("css-loader/lib/getLocalIdent")
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:/]+/g) || []
}
}
const nextConfig = {
target: "serverless",
webpack: (config, options) => {
config.plugins = config.plugins || []
config.plugins = [...config.plugins]
return config
},
}
module.exports = withPlugins(
[
[
withCSS(
withPurgeCSS({
purgeCss: {
purgeCssPaths: ["pages/**/*", "components/**/*"],
extractors: [
{
extractor: TailwindExtractor,
extensions: ["js", "local.css", "css"],
},
],
},
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
// Allow the usage of CSS modules without rewriting our vendors classes
getLocalIdent: (loaderContext, localIdentName, localName, options) => {
const fileName = path.basename(loaderContext.resourcePath)
if (fileName.includes(".local.css") === true) {
return defaultGetLocalIdent(loaderContext, localIdentName, localName, options)
} else {
return localName
}
},
},
}),
),
],
],
nextConfig,
)