Skip to content

pass constants FUNCTIONS_SRC and PUBLISH_DIR to nextOnNetlify #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ const util = require('util')

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

const isStaticExportProject = require('./helpers/isStaticExportProject')
const validateNextUsage = require('./helpers/validateNextUsage')

const pWriteFile = util.promisify(fs.writeFile)
const pCopy = util.promisify(copy)

// * Helpful Plugin Context *
// - Between the prebuild and build steps, the project's build command is run
Expand Down Expand Up @@ -72,16 +70,13 @@ module.exports = {
async onBuild({ constants: { PUBLISH_DIR, FUNCTIONS_SRC = DEFAULT_FUNCTIONS_SRC } }) {
console.log(`** Running Next on Netlify package **`)

await makeDir(PUBLISH_DIR)

// We cannot load `next-on-netlify` (which depends on `next`) at the
// top-level because we validate whether the site is using `next`
// inside `onPreBuild`.
const nextOnNetlify = require('next-on-netlify')
nextOnNetlify()

// Next-on-netlify puts its files into out_functions and out_publish
// Copy files from next-on-netlify's output to the right functions/publish dirs
await makeDir(PUBLISH_DIR)
await Promise.all([pCopy('out_functions/**', FUNCTIONS_SRC), pCopy('out_publish/**', PUBLISH_DIR)])
nextOnNetlify({ functionsDir: FUNCTIONS_SRC, publishDir: PUBLISH_DIR })
},
}

Expand Down
Loading