-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
29 lines (25 loc) · 1002 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
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) => {
// 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}`);
const env = {
CLIENT_PAGE_QUERY_LIMIT: process.env.CLIENT_PAGE_QUERY_LIMIT,
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
ALGOLIA_SEARCH_ONLY_API_KEY: process.env.ALGOLIA_SEARCH_ONLY_API_KEY,
};
// next.config.js object
return {
env,
};
};