@@ -4,13 +4,11 @@ const util = require('util')
44
55const findUp = require ( 'find-up' )
66const makeDir = require ( 'make-dir' )
7- const { copy } = require ( 'cpx' )
87
98const isStaticExportProject = require ( './helpers/isStaticExportProject' )
109const validateNextUsage = require ( './helpers/validateNextUsage' )
1110
1211const pWriteFile = util . promisify ( fs . writeFile )
13- const pCopy = util . promisify ( copy )
1412
1513// * Helpful Plugin Context *
1614// - Between the prebuild and build steps, the project's build command is run
@@ -72,16 +70,13 @@ module.exports = {
7270 async onBuild ( { constants : { PUBLISH_DIR , FUNCTIONS_SRC = DEFAULT_FUNCTIONS_SRC } } ) {
7371 console . log ( `** Running Next on Netlify package **` )
7472
73+ await makeDir ( PUBLISH_DIR )
74+
7575 // We cannot load `next-on-netlify` (which depends on `next`) at the
7676 // top-level because we validate whether the site is using `next`
7777 // inside `onPreBuild`.
7878 const nextOnNetlify = require ( 'next-on-netlify' )
79- nextOnNetlify ( )
80-
81- // Next-on-netlify puts its files into out_functions and out_publish
82- // Copy files from next-on-netlify's output to the right functions/publish dirs
83- await makeDir ( PUBLISH_DIR )
84- await Promise . all ( [ pCopy ( 'out_functions/**' , FUNCTIONS_SRC ) , pCopy ( 'out_publish/**' , PUBLISH_DIR ) ] )
79+ nextOnNetlify ( { functionsDir : FUNCTIONS_SRC , publishDir : PUBLISH_DIR } )
8580 } ,
8681}
8782
0 commit comments