-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnext.config.js
33 lines (29 loc) · 944 Bytes
/
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
const { env } = require('./env/server')
// throws if validation fails
require('./utils/validation')
const { NEXT_PUBLIC_ASSET_PREFIX, BUILD_DIR, DATA_DIR, PUBLIC_DIR } = env;
const isProd = process.env.NODE_ENV !== "development";
// NOTE: __dirname is the dirname where this configuration file is located
const payload = {
reactStrictMode: true,
trailingSlash: true,
basePath:
isProd && NEXT_PUBLIC_ASSET_PREFIX ? NEXT_PUBLIC_ASSET_PREFIX : undefined,
assetPrefix:
isProd && NEXT_PUBLIC_ASSET_PREFIX ? NEXT_PUBLIC_ASSET_PREFIX : undefined,
env: {
DATA_DIR,
PUBLIC_DIR,
},
distDir: BUILD_DIR || '.next',
swcMinify: true,
};
if (!isProd && process.env.ANALYZE) {
// eslint-disable-next-line global-require
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
module.exports = withBundleAnalyzer(payload);
} else {
module.exports = payload;
}