GithubHelp home page GithubHelp logo

now-builder's Introduction

Now Builder for Nuxt.js

npm version npm downloads packagephobia Circle CI Codecov Dependencies Standard JS

The Now Nuxt.js Builder takes a Nuxt.js application, defined by a nuxt.config.js entrypoint and deploys it to Now2 serverless environment.

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

When to use it

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

For more information on why you should use Nuxt.js for your project, see 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 builds and routes in now.json configuration file:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ],
  "routes": [
    { "src": "/_nuxt/.+", "headers": { "Cache-Control": "max-age=31557600" } },
    { "src": "/(.*)", "dest": "/" }
  ]
}

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 Now Monorepo.

Config

serverFiles

  • Type: Array

If you need to include some additional files to the server lambda like a local module or serverMiddleware which are NOT inside static or dist (built by webpack), you can use this option. Each item can be a glob pattern.

Example:

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

Technical Details

Dependencies installation

The installation algorithm of dependencies works as follows:

  • If a package-lock.json is present, npm install is used
  • Otherwise, yarn is used.

NOTE: Using yarn is HIGHLY recommended!

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 in the 8 branch.

License

MIT License

Docs and Builder inspired by Next.js by Zeit.co

Copyright (c) Nuxt Community

now-builder's People

Contributors

renovate[bot] avatar dependabot[bot] avatar unr avatar pi0 avatar renovate-bot avatar tootallnate avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.