-
Notifications
You must be signed in to change notification settings - Fork 0
/
nextConfigDocsInfra.js
78 lines (72 loc) · 2.84 KB
/
nextConfigDocsInfra.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
/**
* See the docs of the Netlify environment variables:
* https://docs.netlify.com/configure-builds/environment-variables/#build-metadata.
*
* A few comments:
* - process.env.CONTEXT === 'production' means that the branch in Netlify was configured as production.
* For example, the `master` branch of the Core team is considered a `production` build on Netlify based
* on https://app.netlify.com/sites/material-ui/settings/deploys#branches.
* - Each team has different site https://app.netlify.com/teams/mui/sites.
* The following logic must be compatible with all of them.
*/
let DEPLOY_ENV = 'development';
// Same as process.env.PULL_REQUEST_ID
if (process.env.CONTEXT === 'deploy-preview') {
DEPLOY_ENV = 'pull-request';
}
if (process.env.CONTEXT === 'production' || process.env.CONTEXT === 'branch-deploy') {
DEPLOY_ENV = 'production';
}
// The 'master' and 'next' branches are NEVER a production environment. We use these branches for staging.
if (
(process.env.CONTEXT === 'production' || process.env.CONTEXT === 'branch-deploy') &&
(process.env.HEAD === 'master' || process.env.HEAD === 'next')
) {
DEPLOY_ENV = 'staging';
}
/**
* ====================================================================================
*/
process.env.DEPLOY_ENV = DEPLOY_ENV;
function withDocsInfra(nextConfig) {
return {
trailingSlash: true,
// Can be turned on when https://github.com/vercel/next.js/issues/24640 is fixed
optimizeFonts: false,
reactStrictMode: true,
...nextConfig,
env: {
BUILD_ONLY_ENGLISH_LOCALE: true, // disable translations by default
// production | staging | pull-request | development
DEPLOY_ENV,
...nextConfig.env,
// https://docs.netlify.com/configure-builds/environment-variables/#git-metadata
// reference ID (also known as "SHA" or "hash") of the commit we're building.
COMMIT_REF: process.env.COMMIT_REF,
// ID of the PR and the Deploy Preview it generated (for example, 1211)
PULL_REQUEST_ID: process.env.REVIEW_ID,
// This can be set manually in the .env to see the ads in dev mode.
ENABLE_AD_IN_DEV_MODE: process.env.ENABLE_AD_IN_DEV_MODE,
// URL representing the unique URL for an individual deploy, e.g.
// https://5b243e66dd6a547b4fee73ae--petsof.netlify.app
NETLIFY_DEPLOY_URL: process.env.DEPLOY_URL,
// Name of the site, its Netlify subdomain; for example, material-ui-docs
NETLIFY_SITE_NAME: process.env.SITE_NAME,
},
experimental: {
scrollRestoration: true,
esmExternals: false,
...nextConfig.experimental,
},
eslint: {
ignoreDuringBuilds: true,
...nextConfig.eslint,
},
typescript: {
// Motivated by https://github.com/vercel/next.js/issues/7687
ignoreBuildErrors: true,
...nextConfig.typescript,
},
};
}
module.exports = withDocsInfra;