-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathnext.config.mjs
75 lines (69 loc) · 1.76 KB
/
next.config.mjs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { withHydrationOverlay } from "@builder.io/react-hydration-overlay/next";
import million from "million/compiler";
import WpAutoImport from "unplugin-auto-import/webpack";
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "img.clerk.com",
},
],
},
webpack(config) {
config.plugins.push(
WpAutoImport({
imports: [
"react",
{
"next/navigation": [
"useRouter",
"useSearchParams",
"useParams",
"usePathname",
"redirect",
"permanentRedirect",
],
"next/link": [["default", "Link"]],
"next/image": [["default", "NImage"]],
"next/script": [["default", "NScript"]],
"react-use": ["useToggle"],
},
],
dirs: ["./src/shared/**"],
}),
);
return config;
},
};
const plugins = [];
const pluginOptions = [
{
id: "million",
options: {
auto: true,
},
},
{
id: "mismatch-hydration",
options: {
appRootSelector: "main",
},
},
];
if (process.env.ANALYZE === "true") {
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: true,
});
plugins.push({ id: "analyzer", plugin: withBundleAnalyzer });
}
plugins.push({ id: "million", plugin: million.next });
plugins.push({ id: "mismatch-hydration", plugin: withHydrationOverlay });
export default () => {
return plugins.reduce((acc, curr) => {
const options = pluginOptions.find((id) => curr.id === id);
if (options && Object.keys(options).length > 0) return curr.plugin(acc, options);
return curr.plugin(acc);
}, nextConfig);
};