-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
44 lines (35 loc) · 1.12 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
const incstr = require('incstr');
const classNames = {};
const generateClassName = incstr.idGenerator({
alphabet: 'abcdefghijklmnopqrstuvwxyz'
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
unoptimized: true,
},
webpack: (config, {dev, isServer}) => {
if (!dev) {
const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');
config.plugins.push(new MangleCssClassPlugin({
classNameRegExp: '(([a-zA-Z-:]*)[\\\\\\\\]*:)*([\\\\\\\\]*!)?-?tw-[a-zA-Z-]([a-zA-Z0-9-]*([\\\\\\\\]*(\\%|\\#|\\.|\\[|\\]|\\/))*)*',
log: process.env.NODE_ENV === 'development',
classGenerator: (original, opts, context) => {
if (classNames[original]) {
return classNames[original];
}
let nextId;
do {
// Class name cannot start with a number.
nextId = generateClassName();
} while (/^[0-9_-]/.test(nextId));
return (classNames[original] = nextId);
}
}));
}
return config;
},
}
module.exports = nextConfig