An example static deployment that makes use of build env to access private npm repositories
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dockerignore
.gitignore
Dockerfile
now.json
package.json
readme.md
yarn.lock

readme.md

now-build-env-starter-static

An example of a static deployment built using private npm modules.

Example URL: https://now-build-env-starter-static-mmzuoenowm.zeit.sh

How to use

Create a readonly npm token:

npm token create --read-only

Create a secret with its value (in this example we call it npm-token):

# replace "MY_TOKEN_VALUE" with the value returned
# by the `npm token` command
now secret add npm-token MY_TOKEN_VALUE

Add a private repo (if you have any):

yarn add @my-team/private-repo

Then you are ready to deploy!

now

Note: this deployment is set to have its source code be public. If you intend for it to be private, set public: false in now.json.

How it Works

In now.json we defined to build env vars:

  • NPM_TOKEN
  • TEXT

NPM_TOKEN is used to authenticate with the npm registry to be able to download private repositories.

TEXT is used to generate a dynamic index.html file that gets placed in /public, which is served statically once the build completes and your deployment is ready.

Finally, .dockerignore is used in order to only upload files into the build stage that are necessary for this project to work.