-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
148 lines (139 loc) · 4.46 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
const packageJson = require('./package.json');
const { i18n } = require('./next-i18next.config');
const trueEnv = ['true', '1', 'yes'];
const NEXTJS_IGNORE_ESLINT = trueEnv.includes(
process.env?.NEXTJS_IGNORE_ESLINT ?? 'false'
);
const NEXTJS_IGNORE_TYPECHECK = trueEnv.includes(
process.env?.NEXTJS_IGNORE_TYPECHECK ?? 'false'
);
// const NEXTJS_DISABLE_SENTRY = trueEnv.includes(
// process.env?.NEXTJS_DISABLE_SENTRY ?? 'false'
// );
// const NEXTJS_SENTRY_UPLOAD_DRY_RUN = trueEnv.includes(
// process.env?.NEXTJS_SENTRY_UPLOAD_DRY_RUN ?? 'false'
// );
const NEXTJS_SENTRY_DEBUG = trueEnv.includes(
process.env?.NEXTJS_SENTRY_DEBUG ?? 'false'
);
const NEXTJS_SENTRY_TRACING = trueEnv.includes(
process.env?.NEXTJS_SENTRY_TRACING ?? 'false'
);
module.exports = {
reactStrictMode: true,
staticPageGenerationTimeout: 1000 * 60 * 2, // 2 minutes
i18n,
sassOptions: {
includePaths: [path.join(__dirname, 'src/assets/styles')],
},
images: {
domains: [
'hkih.production.geniem.io',
'kultus.content.api.hel.fi',
'hkih.stage.geniem',
'kultus.hkih.stage.geniem.io',
'app-staging.hkih.hion.dev',
'kultus.app-staging.hkih.hion.dev',
],
},
env: {
APP_NAME: packageJson.name,
APP_VERSION: packageJson.version,
BUILD_TIME: new Date().toISOString(),
},
swcMinify: true,
// Standalone build
// @link https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files-experimental
output: 'standalone',
experimental: {
/* turbotrace: {
contextDirectory: path.resolve(__dirname, '../..'),
logDetail: true,
}, */
// Prefer loading of ES Modules over CommonJS
// @link {https://nextjs.org/blog/next-11-1#es-modules-support|Blog 11.1.0}
// @link {https://github.com/vercel/next.js/discussions/27876|Discussion}
esmExternals: true,
// Experimental monorepo support
// @link {https://github.com/vercel/next.js/pull/22867|Original PR}
// @link {https://github.com/vercel/next.js/discussions/26420|Discussion}
externalDir: true,
scrollRestoration: true,
// disable in-memory caching
// @link https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#self-hosting-isr
isrMemoryCacheSize: 0,
},
typescript: {
/** Do not run TypeScript during production builds (`next build`). */
ignoreBuildErrors: NEXTJS_IGNORE_TYPECHECK,
tsconfigPath: 'tsconfig.json',
},
eslint: {
ignoreDuringBuilds: NEXTJS_IGNORE_ESLINT,
dirs: ['src'],
},
webpack: (config, { webpack, isServer }) => {
if (!isServer) {
// Fixes npm packages that depend on `fs` module
// @link https://github.com/vercel/next.js/issues/36514#issuecomment-1112074589
// @link https://stackoverflow.com/a/63074348/784642
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
child_process: false,
perf_hooks: false,
};
}
// https://webpack.js.org/configuration/watch/#watchoptions
config.watchOptions = {
poll: 1000, // Check for changes every second
aggregateTimeout: 300, // Delay 0.3s before rebuilding to group changes
ignored: ['**/node_modules'],
};
config.resolve.alias = {
...config.resolve.alias,
'~hds-core': path.resolve(__dirname, './node_modules/hds-core'),
'~hds-design-tokens': path.resolve(
__dirname,
'./node_modules/hds-design-tokens'
),
'~react-toastify': path.resolve(
__dirname,
'./node_modules/react-toastify'
),
};
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/
config.plugins.push(
new webpack.DefinePlugin({
__SENTRY_DEBUG__: NEXTJS_SENTRY_DEBUG,
__SENTRY_TRACING__: NEXTJS_SENTRY_TRACING,
})
);
config.module.rules.push({
test: /\.svg$/,
issuer: /\.(js|ts)x?$/,
use: [
{
loader: '@svgr/webpack',
// https://react-svgr.com/docs/webpack/#passing-options
options: {
svgo: true,
// @link https://github.com/svg/svgo#configuration
svgoConfig: {
multipass: false,
datauri: 'base64',
js2svg: {
indent: 2,
pretty: false,
},
},
},
},
],
});
return config;
},
};