-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.js
More file actions
75 lines (67 loc) · 2.25 KB
/
next.config.js
File metadata and controls
75 lines (67 loc) · 2.25 KB
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
/* eslint-disable global-require */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-var-requires */
const { withSentryConfig } = require('@sentry/nextjs');
const path = require('path');
/** @type {import('next').NextConfig} */
const nextConfig = {
compiler: {
styledComponents: {
ssr: true,
},
},
reactStrictMode: process.env.STRICT_MODE,
swcMinify: true,
output: 'standalone',
i18n: {
locales: ['en', 'ru'],
defaultLocale: process.env.DEFAULT_LOCALE || 'en',
},
eslint: {
ignoreDuringBuilds: true,
},
sentry: {
disableServerWebpackPlugin: process.env.SENTRY_DISABLED === '1',
disableClientWebpackPlugin: process.env.SENTRY_DISABLED === '1',
widenClientFileUpload: true,
},
webpack(config, { dev, isServer }) {
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};
if (dev && !isServer && process.env.NEXT_PUBLIC_WDYR === '1') {
const originalEntry = config.entry;
config.entry = async () => {
const wdrPath = path.resolve(__dirname, './src/utils/wdyr.ts');
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes(wdrPath)) {
entries['main.js'].push(wdrPath);
}
return entries;
};
}
if (!dev && !isServer && !process.env.INCLUDE_SCRIPTS_TO_MAIN_BUNDLE) {
config.externals = {
React: 'react',
ReactDOM: 'react-dom',
};
}
return config;
},
};
module.exports =
process.env.NODE_ENV === 'development' && process.env.ANALYZE === 'true'
? require('@next/bundle-analyzer')({})(nextConfig)
: withSentryConfig(nextConfig, {
errorHandler: (err, invokeErr, compilation) => {
compilation.warnings.push(`@sentry/nextjs: ${err.message}`);
},
silent: true,
hideSourcemaps: true,
ignore: ['node_modules'],
});