-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnext.config.js
35 lines (31 loc) · 923 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
34
35
const { readFileSync } = require('fs');
const { PHASE_PRODUCTION_SERVER } = require('next/constants');
const packageJSON = JSON.parse(readFileSync('./package.json', 'utf8'));
const APP_NAME = packageJSON.name;
const APP_REPOSITORY_URL = packageJSON.repository.url.replace(/git\+|\.git/gi, '');
const APP_VERSION = packageJSON.version;
/** @type {(phase: string) => import('next').NextConfig} */
module.exports = phase => {
if (phase === PHASE_PRODUCTION_SERVER) {
[
['APP_NAME', APP_NAME],
['APP_REPOSITORY_URL', APP_REPOSITORY_URL],
['APP_VERSION', APP_VERSION],
['TZ', process.env.TZ],
].forEach(([name, value]) => {
if (!value) throw new Error(`${name} is not defined`);
});
}
return {
env: {
APP_NAME,
APP_REPOSITORY_URL,
APP_VERSION,
},
experimental: {
appDir: true,
},
reactStrictMode: true,
swcMinify: true,
};
};