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.
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.
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": "s-maxage=31536000" } },
{ "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.
- 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/**"]
}
}
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!
To install private npm modules, define NPM_TOKEN
as a build environment in now.json
.
The Node.js version used is the latest in the 8 branch.
Docs and Builder inspired by Next.js by Zeit.co
Copyright (c) Nuxt Community