-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.mjs
87 lines (78 loc) · 2.59 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
76
77
78
79
80
81
82
83
84
85
86
87
/* eslint-disable @typescript-eslint/ban-ts-comment */
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
* This is especially useful for Docker builds.
*/
!process.env.SKIP_ENV_VALIDATION && (await import('./src/env.mjs'));
import { withSentryConfig } from '@sentry/nextjs';
import { execSync } from 'child_process';
const commitHash = execSync('git rev-parse --short HEAD').toString()?.replace('\n', '');
const timestamp = execSync('git log -1 --format=%ct').toString()?.replace('\n', '');
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
/**
* If you have the "experimental: { appDir: true }" setting enabled, then you
* must comment the below `i18n` config out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
i18n: {
locales: ['en'],
defaultLocale: 'en'
},
typescript: {
ignoreBuildErrors: true
},
eslint: {
ignoreDuringBuilds: true
},
swcMinify: true,
env: {
NEXT_PUBLIC_COMMIT_HASH: commitHash,
NEXT_PUBLIC_COMMIT_TIMESTAMP: timestamp,
SENTRY_IGNORE_API_RESOLUTION_ERROR: '1'
},
images: {
domains: ['cdn.discordapp.com', 'avatars.githubusercontent.com', 'api.producthunt.com']
},
webpack(config) {
// Grab the existing rule that handles SVG imports
// @ts-ignore
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));
config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/ // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: /url/ }, // exclude if *.svg?url
use: ['@svgr/webpack']
}
);
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;
config.experiments = {
...config.experiments,
topLevelAwait: true
};
return config;
},
sentry: {
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
// for client-side builds. (This will be the default starting in
// `@sentry/nextjs` version 8.0.0.) See
// https://webpack.js.org/configuration/devtool/ and
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
// for more information.
hideSourceMaps: true,
disableServerWebpackPlugin: true,
disableClientWebpackPlugin: true
}
};
export default withSentryConfig(config);