forked from opennextjs/opennextjs-netlify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetNextConfig.js
26 lines (19 loc) · 871 Bytes
/
getNextConfig.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
'use strict'
const { resolve } = require('path')
const { defaultFailBuild } = require('./defaultFailBuild')
const moize = require('moize')
// Load next.config.js
const getNextConfig = async function (params = {}) {
const { failBuild = defaultFailBuild, publishPath = '.' } = params
// We cannot load `next` at the top-level because we validate whether the
// site is using `next` inside `onPreBuild`.
const { PHASE_PRODUCTION_BUILD } = require('next/constants')
const loadConfig = require('next/dist/next-server/server/config').default
try {
return await loadConfig(PHASE_PRODUCTION_BUILD, resolve(publishPath))
} catch (error) {
return failBuild('Error loading your next.config.js.', { error })
}
}
const moizedGetNextConfig = moize(getNextConfig, { maxSize: 1e3, isPromise: true, isDeepEqual: true })
module.exports = moizedGetNextConfig