@nuxtjs/now-builder

![now-builder](https://user-images.githubusercontent.com/904724/61308402-7a752d00-a7f0-11e9-9502-23731ccd00fd.png)

This package has been renamed to @nuxtjs/vercel-builder.
Last updated 4 months ago by danielroe .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @nuxtjs/now-builder 
SYNC missed versions from official npm registry.

now-builder

Nuxt.js Now Builder

npm version npm downloads packagephobia Github actions status Codecov Dependencies Standard JS

This Vercel builder takes a Nuxt.js application defined by a nuxt.config entrypoint and deploys it as a serverless function in a Vercel environment.

It features built-in caching of node_modules and the yarn global cache (even with dependency changes!) and multi-stage build for fast and small deployments.

When to use it

If you are using the Vercel and need SSR rendering, @nuxtjs/now-builder is the ideal way to ship a fast, production-ready Nuxt.js application that scales automatically.

If you do not need SSR rendering, consider deploying a statically generated Nuxt.js application instead. See this guide from Vercel for more information.

You can also find more information on the Nuxt.js website.

How to use it

The first step is to set up a Nuxt.js project.

To get started, make sure you have installed the Nuxt.js dependencies with the following command:

yarn add nuxt

Then, in your project directory, create a pages directory with some example pages, for example; the home index page, pages/index.vue:

<template>
  <div>
    Works!
  </div>
</template>

Create a simple nuxt.config.js file:

export default {
  head: {
    title: "My Nuxt.js Application!"
  }
};

Then define the build in now.json:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ]
}

Upon deployment, you will get a URL like this: https://nuxtjs-8fnzfb1ci.now.sh

See Basic Example for a more complete deployable example.

See Deploying two Nuxt apps side-by-side for details on deploying two Nuxt apps in one monorepo.

Using with TypeScript

now-builder supports TypeScript runtime compilation, though it does so in a slightly different way from @nuxt/typescript-runtime. It adds in a pre-compilation step as part of building the lambda for files not compiled by Webpack, such as nuxt.config.ts, local modules and serverMiddleware.

References to original TS files in strings outside of modules or serverMiddleware may therefore cause unexpected errors.

Configuration

serverFiles

  • Type: Array

If you need to include files in the server lambda that are not built by webpack or within static/, such as a local module or serverMiddleware, you may specify them with this option. Each item can be a glob pattern.

Example:

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {
        "serverFiles": ["server-middleware/**"]
      }
    }
  ]
}

generateStaticRoutes

  • Type: Boolean
  • Default: false

To pre-render routes during the build using nuxt generate set this to true. Routes that are not generated will fallback to the server lambda. You will need to specify the routes to be generated in your nuxt.config.

Example:

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {
        "generateStaticRoutes": true
      }
    }
  ]
}

tscOptions

  • Type: Object

If you need to pass TypeScript compiler options to override your tsconfig.json, you can pass them here. See the TypeScript documentation for valid options. Example:

{
  "src": "nuxt.config.ts",
  "use": "@nuxtjs/now-builder",
  "config": {
    "tscOptions": {
      "sourceMap": false
    }
  }
}

You can also include a tsconfig.now.json file alongside your tsconfig.json file. The compilerOptions from those files, along with any tscOptions passed through now.json, will be merged and the resulting options used to compile your nuxt.config.ts, local modules and serverMiddleware.

Technical details

Dependency installation

Package dependencies are installed with either npm (if a package-lock.json is present) or yarn.

NOTE: Using yarn is HIGHLY recommended due to its autoclean functionality , which can decrease lambda size.

Private npm modules

To install private npm modules, define NPM_TOKEN as a build environment in now.json.

Node.js version

The Node.js version used is the latest 12.x release. Alternatively, you can specify Node 10 in your package.json - see Vercel documentation.

now-build script support

This builder will run a given custom build step if you have added a now-build key under scripts in package.json.

Troubleshooting

Environment variables

Because of Nuxt.js' approach to environment variables, environment variables present at build time will be compiled into the lambda. They may also be required at runtime, depending on how you are consuming them.

You may, therefore, need to include them in your now.json in both the env and build.env keys (see Vercel documentation). For example:

  "env": {
    "MY_VARIABLE": true
  },
  "build": {
    "env": {
      "MY_VARIABLE": true
    }
  }

License

MIT License

Documentation and builder inspired by Next.js by Vercel

Copyright (c) Nuxt Community

Current Tags

  • 0.17.3-beta.0                                ...           beta (4 months ago)
  • 0.17.3                                ...           latest (4 months ago)

62 Versions

  • 0.17.3 [deprecated]           ...           4 months ago
  • 0.17.3-beta.0                                ...           4 months ago
  • 0.17.2 [deprecated]           ...           6 months ago
  • 0.18.0-beta.1                                ...           6 months ago
  • 0.17.1 [deprecated]           ...           8 months ago
  • 0.18.0-beta.0                                ...           8 months ago
  • 0.17.0 [deprecated]           ...           9 months ago
  • 0.16.6 [deprecated]           ...           a year ago
  • 0.16.5 [deprecated]           ...           a year ago
  • 0.16.4 [deprecated]           ...           a year ago
  • 0.16.3 [deprecated]           ...           a year ago
  • 0.16.2 [deprecated]           ...           a year ago
  • 0.16.1 [deprecated]           ...           a year ago
  • 0.16.0 [deprecated]           ...           a year ago
  • 0.15.3 [deprecated]           ...           a year ago
  • 0.15.2 [deprecated]           ...           a year ago
  • 0.15.1 [deprecated]           ...           a year ago
  • 0.15.0 [deprecated]           ...           a year ago
  • 0.14.6 [deprecated]           ...           a year ago
  • 0.14.5 [deprecated]           ...           a year ago
  • 0.14.4 [deprecated]           ...           a year ago
  • 0.14.3 [deprecated]           ...           a year ago
  • 0.14.2 [deprecated]           ...           a year ago
  • 0.14.1 [deprecated]           ...           2 years ago
  • 0.14.0 [deprecated]           ...           2 years ago
  • 0.13.1 [deprecated]           ...           2 years ago
  • 0.13.0 [deprecated]           ...           2 years ago
  • 0.12.3 [deprecated]           ...           2 years ago
  • 0.12.2 [deprecated]           ...           2 years ago
  • 0.12.1 [deprecated]           ...           2 years ago
  • 0.12.0 [deprecated]           ...           2 years ago
  • 0.11.0 [deprecated]           ...           2 years ago
  • 0.10.1 [deprecated]           ...           2 years ago
  • 0.10.0 [deprecated]           ...           2 years ago
  • 0.9.0 [deprecated]           ...           2 years ago
  • 0.8.3 [deprecated]           ...           2 years ago
  • 0.8.2 [deprecated]           ...           2 years ago
  • 0.8.1 [deprecated]           ...           2 years ago
  • 0.8.0 [deprecated]           ...           2 years ago
  • 0.7.3 [deprecated]           ...           2 years ago
  • 0.7.2 [deprecated]           ...           2 years ago
  • 0.7.1 [deprecated]           ...           2 years ago
  • 0.7.0 [deprecated]           ...           2 years ago
  • 0.6.0 [deprecated]           ...           2 years ago
  • 0.5.0 [deprecated]           ...           2 years ago
  • 0.4.0 [deprecated]           ...           2 years ago
  • 0.3.0 [deprecated]           ...           2 years ago
  • 0.2.0 [deprecated]           ...           2 years ago
  • 0.1.0 [deprecated]           ...           2 years ago
  • 0.0.0-alpha.13                                ...           2 years ago
  • 0.0.0-alpha.12                                ...           2 years ago
  • 0.0.0-alpha.11                                ...           2 years ago
  • 0.0.0-alpha.10                                ...           2 years ago
  • 0.0.0-alpha.9                                ...           2 years ago
  • 0.0.0-alpha.8                                ...           2 years ago
  • 0.0.0-alpha.7                                ...           2 years ago
  • 0.0.0-alpha.6                                ...           2 years ago
  • 0.0.0-alpha.5                                ...           2 years ago
  • 0.0.0-alpha.4                                ...           2 years ago
  • 0.0.0-alpha.3                                ...           2 years ago
  • 0.0.0-alpha.2                                ...           2 years ago
  • 0.0.0-alpha.1                                ...           2 years ago
Downloads
Today 0
This Week 1
This Month 2
Last Day 1
Last Week 0
Last Month 9
Dependencies (8)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |