Skip to content

Commit 45e3477

Browse files
pass constants FUNCTIONS_SRC and PUBLISH_DIR to nextOnNetlify (#49)
1 parent 24b42fc commit 45e3477

File tree

8 files changed

+2341
-3399
lines changed

8 files changed

+2341
-3399
lines changed

index.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ const util = require('util')
44

55
const findUp = require('find-up')
66
const makeDir = require('make-dir')
7-
const { copy } = require('cpx')
87

98
const isStaticExportProject = require('./helpers/isStaticExportProject')
109
const validateNextUsage = require('./helpers/validateNextUsage')
1110

1211
const 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

Comments
 (0)