Prevent Uploading Source Paths with `.nowignore`

Using a .nowignore file to prevent the uploading of source paths

Now supports configuration required to ignore source files and paths within your project. With a .nowignore file in your project directory, a source path can be prevented from being uploaded to Now.

File Syntax

The syntax of a .nowignore file matches that of the popular .gitignore file used in ignoring files when uploading to GitHub.

An example of a .nowignore file that prevents an /image directory and /private.html file within a project from being uploaded to Now would look like this:


A .nowignore configuration file.

Uploaded Files

All files within your project are uploaded to Now if there are no builds with specific source targets and no source path is specified to be excluded in a .nowignore configuration file.

Worthy of note is that not all uploaded files are served on Now. So, what files are served?

Served Files

By default, all uploaded files are served statically on Now if no builds are configured within a now.json file.

If a build step exists in the now.json configuration file, the non-targeted files are prevented from being deployed and served on Now.

An example of a now.json file with Builds and src properties is shown below:

  "version": 2,
  "name": "static",
  "builds": [
    { "src": "index.html", "use": "@now/static" },
    { "src": "style.css", "use": "@now/static" }

A now.json configuration file that specifies a Builder.

The use of a .nowignore configuration file allows you to keep private files safe and also makes your deployment faster by uploading only the essential files.

How Was This Guide?

Written By
Written by unicodeveloperunicodeveloper
on January 24th 2019