Skip to content

Instantly share code, notes, and snippets.

@deptno
Created October 22, 2018 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deptno/40bede45bf6dc5b1426a4d446b1945a8 to your computer and use it in GitHub Desktop.
Save deptno/40bede45bf6dc5b1426a4d446b1945a8 to your computer and use it in GitHub Desktop.
Serverless next.js export hack
import loadConfig from 'next/dist/server/config'
import {PHASE_EXPORT} from 'next/constants'
import exporter from 'next/dist/export'
export const exports = async (event, context, callback) => {
const dir = '.'
const result = await exporter(dir,
{
silent: false,
outdir: 'out',
},
{
...loadConfig(PHASE_EXPORT, dir),
async exportPathMap() {
return {
'/': {
page: '/index'
}
}
}
})
return {
statusCode: 201,
body: 'OK'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment