File tree 4 files changed +11
-9
lines changed
4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change
1
+ exports . defaultFailBuild = function ( message , { error } ) {
2
+ throw new Error ( `${ message } \n${ error . stack } ` )
3
+ }
Original file line number Diff line number Diff line change 2
2
3
3
const { resolve } = require ( 'path' )
4
4
5
+ const { defaultFailBuild } = require ( './defaultFailBuild' )
5
6
const moize = require ( 'moize' )
6
7
7
8
// Load next.config.js
8
- const getNextConfig = async function ( failBuild = defaultFailBuild ) {
9
+ const getNextConfig = async function ( failBuild = defaultFailBuild , publishPath = '.' ) {
9
10
// We cannot load `next` at the top-level because we validate whether the
10
11
// site is using `next` inside `onPreBuild`.
11
12
const { PHASE_PRODUCTION_BUILD } = require ( 'next/constants' )
12
13
const loadConfig = require ( 'next/dist/next-server/server/config' ) . default
13
14
14
15
try {
15
- return await loadConfig ( PHASE_PRODUCTION_BUILD , resolve ( '.' ) )
16
+ return await loadConfig ( PHASE_PRODUCTION_BUILD , resolve ( publishPath ) )
16
17
} catch ( error ) {
17
18
return failBuild ( 'Error loading your next.config.js.' , { error } )
18
19
}
19
20
}
20
21
21
22
const moizedGetNextConfig = moize ( getNextConfig , { maxSize : 1e3 , isPromise : true } )
22
23
23
- const defaultFailBuild = function ( message , { error } ) {
24
- throw new Error ( `${ message } \n${ error . stack } ` )
25
- }
26
-
27
24
module . exports = moizedGetNextConfig
Original file line number Diff line number Diff line change 1
1
// Get the NextJS distDir specified in next.config.js
2
2
const { join } = require ( 'path' )
3
+
3
4
const getNextConfig = require ( '../../../helpers/getNextConfig' )
5
+ const { defaultFailBuild } = require ( '../../../helpers/defaultFailBuild' )
4
6
5
- const getNextDistDir = async ( ) => {
6
- const nextConfig = await getNextConfig ( )
7
+ const getNextDistDir = async ( publishPath ) => {
8
+ const nextConfig = await getNextConfig ( defaultFailBuild , publishPath )
7
9
8
10
return join ( '.' , nextConfig . distDir )
9
11
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const getNextDistDir = require('../helpers/getNextDistDir')
6
6
// Copy the NextJS' static assets from NextJS distDir to Netlify publish folder.
7
7
// These need to be available for NextJS to work.
8
8
const copyNextAssets = async ( publishPath ) => {
9
- const nextDistDir = await getNextDistDir ( )
9
+ const nextDistDir = await getNextDistDir ( publishPath )
10
10
const staticAssetsPath = join ( nextDistDir , 'static' )
11
11
if ( ! existsSync ( staticAssetsPath ) ) {
12
12
throw new Error (
You can’t perform that action at this time.
0 commit comments