Builds

Builds are a step of deployments that transform sources into production ready outputs. Builds result in either Static Files, or Lambdas (which execute code and serve a dynamic response for every request).

Builds are defined in the now.json configuration file using the builds property:

{
  "builds": [{ "src": "*.js", "use": "@now/node" }]
}

The above example instructs Now to consider all files with a .js extension (the pattern is defined in the src property) and pass them to an npm module named @now/node.

This @now/node module is called a Builder.

Builders take in all the files matched by the src property and transform those source files to a production-ready output.

Sources and Outputs

Sources are files that already exist in your project before deploying and can be used to define the output.

Outputs are files that are used for the deployment. The output can be either a list of static files, Lambdas, or of both. The output is defined entirely by which, if any, Builder is used.

When deploying with Now, if your project has no now.json file, or has one but no builds property defined, the projects source files will be deployed directly as the output.

However, if you define a builds step, Now will only include the outputs that the Builders produce in the resulting deployment.

Note: Now will only include Builder outputs as a security precaution, if there are builds defined, to avoid serving unintended files to the public.

Configuration

Creating a now.json file in a project, as mentioned above, will allow Now deployments to utilise the source and create a production-ready output through the builds property.

The builds property is an array that contains Build steps, consisting of at least a src and a use property.

The files matched by the src property, as a glob, defined in the Build object of the builds property are called the source. The output is what gets generated by a Builder which can consist of:

  • Static Files - Files that are immediately available without any invocation of code.
  • Lambdas - Serverless functions that are invoked upon request and serve a dynamic response.

The Builder responsible for handling the source is defined in the use property, within a build step of the builds array.

Builders

The driving force behind the Builds step of Now are the Builders. Each Builder takes the source it is given and produces an output, depending on the purpose of the builder.

Official Builders

To get you started with your project quickly and easily, we have made a set of official Builders. You can find the full list of official builders in the sidebar to the left.

Creating a Builder

If you would like to learn how to create a custom Builder, follow the Builder Developer Guide.

Parallelization

Every file matched by the src property (mentioned above) will trigger a new Build. All of those Builds are going to run in parallel after the deployment is created.

This means that each Builder defined in the builds property will run asynchronously of each other and produce their intended output without being blocked on a thread.

Ultimately, the build step will produce the output much faster than running the Builds in series.

Build Environment Variables

Environment variables can be passed to builds in the now.json configuration file via a build.env property.

Limits

Build Sources Limit

With the exception of the use of the @now/static Builder – which simply allows you to move static files to the final deployment – when other Builders are in use in a configuration, Builds usage has limits based on the number of targeted source files overall for the account or team.

These limitations are based on which type of plan your account or team has:

  • On the Free plan, there is a limit of 32 build sources per hour and 100 build sources per day.
  • On the Unlimited plan, there is a limit of 512 build sources per hour and 3000 build sources per day.

To visualize this, take the following examples:

With a project that has 512 JavaScript files that are targeted by the @now/node Builder in a build step within a now.json configuration file (with no other build steps), the deployment will be accepted but another will not be possible for an hour.

If that same project adds a build step to target a single Go file with the @now/go Builder, making the total sources equal 513 files, the deployment will fail as it would reach the limit of build sources.

Builds Timeout

If a Build is in progression for 15 minutes, the Build will timeout and throw an error.