-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
102 lines (87 loc) · 2.63 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const { withSentryConfig } = require("@sentry/nextjs");
const {
locales,
defaultLocale,
domains,
previewDomains,
localDomains,
} = require("./src/locales/locales.json");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const withMDX = require("@next/mdx")();
const { match } = require("ts-pattern");
const pkg = require("./package.json");
const VERSION = `v${pkg.version}`;
console.log("Version", VERSION);
const config = withBundleAnalyzer(
withMDX({
// Build-time env variables
env: {
VERSION,
},
i18n: {
locales,
defaultLocale,
domains: match(process.env.NEXT_PUBLIC_VERCEL_ENV)
.with("development", () => localDomains)
.with("preview", () => previewDomains)
.with("production", () => domains)
.otherwise(() => localDomains),
localeDetection: false,
},
/**
* Jotai documentation recommends to transpile jotai-devtools, however
* this causes an error, so we leave it out for now.
*/
// transpilePackages: ["jotai-devtools"],
pageExtensions: ["js", "ts", "tsx", "mdx"],
images: {
domains: ["www.datocms-assets.com"],
},
webpack(config, { dev, isServer, defaultLoaders }) {
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader",
});
/* Enable source maps in production */
if (!dev) {
config.devtool = "source-map";
for (const plugin of config.plugins) {
if (plugin.constructor.name === "UglifyJsPlugin") {
plugin.options.sourceMap = true;
break;
}
}
if (config.optimization && config.optimization.minimizer) {
for (const plugin of config.optimization.minimizer) {
if (plugin.constructor.name === "TerserPlugin") {
plugin.options.sourceMap = true;
break;
}
}
}
}
return config;
},
})
);
// Injected content via Sentry wizard below
module.exports = withSentryConfig(
config,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
// Suppresses source map uploading logs during build
silent: true,
},
{
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
}
);