-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
26 lines (23 loc) · 1012 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
const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } = require('next/constants')
// This uses phases as outlined here: https://nextjs.org/docs/#custom-configuration
module.exports = (phase) => {
console.log(phase)
// when started in development mode `next dev` or `npm run dev` regardless of the value of STAGING environmental variable
const isDev = phase === PHASE_DEVELOPMENT_SERVER
// when `next build` or `npm run build` is used
const isProd = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== '1'
// when `next build` or `npm run build` is used
const isStaging = phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === '1'
console.log(`isDev:${isDev} isProd:${isProd} isStaging:${isStaging}`)
// next.config.js object
return {
publicRuntimeConfig: {
// can add static folder instead public folder.
staticFolder: '/public'
},
serverRuntimeConfig: {
API_URL: process.env.API_URL,
JWT_SECRET: process.env.JWT_SECRET
}
}
}