Skip to content
This repository has been archived by the owner on Feb 20, 2025. It is now read-only.

feat: add post build script #729

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ Alternatively, you can inline your entire `.npmrc` file in a `NPM_RC` environmen

The newest available Node.js version is automatically selected. If your packages depend on a particular major release Node.js version, you can specify the version in your `package.json` - see [Vercel documentation](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version).

### `vercel-build` script support
### `vercel-build`, `post-vercel-build` script support

This builder will run a given [custom build step](https://vercel.com/docs/runtimes#advanced-usage/advanced-node-js-usage/custom-build-step-for-node-js) if you have added a `vercel-build` key under `scripts` in `package.json`.
This builder will run a given [custom build step](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#custom-build-step-for-node.js) if you have added a `vercel-build` or `post-vercel-build` key under `scripts` in `package.json`.

`vercel-build` script will run before nuxt build and `post-vercel-build` will run after then.

## Deploying additional serverless functions

Expand Down
10 changes: 10 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ export async function build (opts: BuildOptions & { config: NuxtBuilderConfig })
], spawnOpts)
}

// ----------------- Post build -----------------
const postBuildSteps = ['post-vercel-build', 'post-now-build']
for (const step of postBuildSteps) {
if (pkg.scripts && Object.keys(pkg.scripts).includes(step)) {
startStep(`Post build (${step})`)
await runPackageJsonScript(entrypointPath, step, spawnOpts)
break
}
}

// ----------------- Install dependencies -----------------
startStep('Install dependencies')

Expand Down