Skip to content

Instantly share code, notes, and snippets.

@talaikis
Created June 22, 2020 07:49
Show Gist options
  • Save talaikis/f729aa9c2a0921b93ed121151142ae32 to your computer and use it in GitHub Desktop.
Save talaikis/f729aa9c2a0921b93ed121151142ae32 to your computer and use it in GitHub Desktop.
const { join } = require('path')
const { writeFile, unlink } = require('fs')
const functions = [
{ p: join(__dirname, 'handlers', 'user', 'confirm', 'index.js'), o: join(__dirname, 'build', 'userConfirm.js') },
{ p: join(__dirname, 'handlers', 'user', 'delete', 'index.js'), o: join(__dirname, 'build', 'userDelete.js') },
{ p: join(__dirname, 'handlers', 'user', 'edit', 'index.js'), o: join(__dirname, 'build', 'userEdit.js') },
{ p: join(__dirname, 'handlers', 'user', 'get', 'index.js'), o: join(__dirname, 'build', 'userGet.js') },
{ p: join(__dirname, 'handlers', 'user', 'signin', 'index.js'), o: join(__dirname, 'build', 'signin.js') },
{ p: join(__dirname, 'handlers', 'user', 'signup', 'index.js'), o: join(__dirname, 'build', 'signup.js') },
/* ... */
{ p: join(__dirname, 'handlers', 'billing', 'stripe', 'webhook', 'index.js'), o: join(__dirname, 'build', 'stripeWebhook.js') },
{ p: join(__dirname, 'handlers', 'admin', 'marketing', 'email', 'send.js'), o: join(__dirname, 'build', 'newsSend.js') },
{ p: join(__dirname, 'handlers', 'admin', 'marketing', 'push', 'send.js'), o: join(__dirname, 'build', 'pushSend.js') },
{ p: join(__dirname, 'handlers', 'admin', 'add-admin', 'index.js'), o: join(__dirname, 'build', 'addAdmin.js') }
]
;(() => {
for (const func of functions) {
require('@zeit/ncc')(func.p, {
cache: false,
externals: [],
filterAssetBase: process.cwd(),
minify: true,
sourceMap: false,
sourceMapBasePrefix: '../',
sourceMapRegister: false,
watch: false,
v8cache: false,
quiet: false,
debugLog: false
}).then(({ code, map, assets }) => {
unlink(func.o, (err) => {
if (err) console.log(err)
writeFile(func.o, code, (err) => {
if (err) console.log(err)
console.log(`Wrote ${func}`)
})
})
})
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment