-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
74 lines (67 loc) · 2.04 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
const { withSentryConfig } = require('@sentry/nextjs');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const test = process.env.NEXT_PUBLIC_APP_ENV === 'test';
const analyse = process.env.NEXT_BUILD_ANALYZE === 'true';
const debug = process.env.NEXT_BUILD_DEBUG === 'true';
/** @type {import('next').NextConfig} */
let config = {
reactStrictMode: true,
// swcMinify: true, // 7x faster than Terser
eslint: {
ignoreDuringBuilds: test || analyse,
dirs: ['src', 'typings'],
},
typescript: {
ignoreBuildErrors: test || analyse,
},
images: {
domains: ['transfer.deepsquare.run'],
},
productionBrowserSourceMaps: true,
experimental: { serverComponentsExternalPackages: ['mongoose'] },
webpack: (config, { buildId, isServer }) => {
config.plugins.forEach((plugin) => {
if (plugin.constructor.name === 'DefinePlugin') {
plugin.definitions = {
...plugin.definitions,
'process.env.APP_RELEASE': JSON.stringify(buildId),
'process.env.NEXT_PUBLIC_APP_RELEASE': JSON.stringify(buildId),
};
process.env.SENTRY_RELEASE = buildId;
}
});
if (debug) {
config.optimization.minimize = false;
}
config.experiments = { ...config.experiments, topLevelAwait: true };
if (!isServer) {
config.plugins.push(
new MonacoWebpackPlugin({
languages: ['yaml'],
filename: 'static/[name].worker.js',
customLanguages: [
{
label: 'yaml',
entry: 'monaco-yaml',
worker: {
id: 'monaco-yaml/yamlWorker',
entry: 'monaco-yaml/yaml.worker',
},
},
],
}),
);
}
return config;
},
};
try {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: analyse,
});
config = withBundleAnalyzer(config);
} catch (_) {}
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
config = withSentryConfig(config, { silent: true }, { hideSourceMaps: true });
}
module.exports = config;