-
Notifications
You must be signed in to change notification settings - Fork 165
/
next.config.js
37 lines (33 loc) · 1023 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
36
37
const isProd = process.env.NODE_ENV === 'production'
/*
* Gets the BASE_PATH from the command used to start this app.
* If BASE_PATH is specified but it does not start with a "/"
* then add it.
* https://stackoverflow.com/questions/60452054/nextjs-deploy-to-a-specific-url-path
*/
function getBasePath() {
var basePath = undefined
if (isProd && process.env.BASE_PATH) {
if (process.env.BASE_PATH.startsWith("/")) {
basePath = process.env.BASE_PATH;
} else {
basePath = "/" + process.env.BASE_PATH;
}
}
return basePath
}
const basePath = getBasePath()
console.warn(
// "Are you publishing to <username>.github.io ? then [basePath] should be empty.\n" +
// "Are you publishing to <username>.github.io/<repository> ? then [basePath] should be /<repository>.\n" +
`P.S. [basePath] is {${basePath}}`
)
const nextConfig = {
reactStrictMode: true,
basePath: basePath,
assetPrefix: basePath,
publicRuntimeConfig: {
basePath: basePath,
},
}
module.exports = nextConfig