Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 94c582c

Browse files
atinuxESnarkdebs-obrienpi0
authored
chore: v2.13.0 (#1922)
* chore: update plugins * docs: update generate.ignore * ko: api translations added (#1944) * Create components-client-only.md * Create configuration-builddir.md * Create configuration-cli.md * Create configuration-dir.md * Create $nuxt.md * Create configuration-extend-plugins.md * chore: simplify installation * feat: add components option * fix: correct meta description * docs: add telemetry configuration * docs: update typo * docs: generate updated * docs: export command * docs: add export to commands * docs: remove cross-env * docs: update export command * docs: remove cross env * docs: update mode add target page * docs: link mode and target * docs: add target to menu * docs: default server for target * docs: target explanation * docs: target explanation * docs: add target to commands * docs: update usage for context 👀 * docs: fixes after meeting * docs: fix commands * docs: improve commands * docs: improve crawler explanation * docs: runtimeConfig * docs: improvements on api * fix: link to article * fix: link to article * docs: improvements on runtimeConfig * blog: going full static * blog: env post * fix: link * fix: link in blog * docs: update routes * blog: update description full static * docs: add video * focs: fix typo * docs: 2.13 Co-authored-by: ESnark <31977180+ESnark@users.noreply.github.com> Co-authored-by: debs-obrien <debs_obrien@yahoo.co.uk> Co-authored-by: Pooya Parsa <pyapar@gmail.com>
1 parent d102479 commit 94c582c

39 files changed

+993
-281
lines changed

de/api/configuration-dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description: Define the development or production mode.
1313
This property is overwritten by [nuxt commands](/guide/commands):
1414

1515
- `dev` is forced to `true` with `nuxt`
16-
- `dev` is forced to `false` with `nuxt build`, `nuxt start` and `nuxt generate`
16+
- `dev` is forced to `false` with `nuxt build`, `nuxt start`, `nuxt generate` and `nuxt export`.
1717

1818
This property should be used when using [Nuxt.js programmatically](/api/nuxt):
1919

de/api/configuration-generate.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ description: Configure the generation of your universal web application to a sta
99

1010
> Configure the generation of your universal web application to a static web application.
1111
12-
When launching `nuxt generate` or calling `nuxt.generate()`, Nuxt.js will use the configuration defined in the `generate` property.
12+
When launching `nuxt export` or `nuxt generate` or calling `nuxt.generate()`, Nuxt.js will use the configuration defined in the `generate` property.
1313

1414
## dir
1515

1616
- Type: `String`
1717
- Default: `'dist'`
1818

19-
Directory name created by `nuxt generate`.
19+
Directory name created by `nuxt export` or nuxt `generate`.
2020

2121
## fallback
2222

@@ -66,7 +66,9 @@ You can change the default configuration of [html-minifier](https://github.com/k
6666

6767
- Type: `Array`
6868

69-
[Dynamic routes](/guide/routing#dynamic-routes) are ignored by the `generate` command.
69+
As of Nuxt v2.13 there is a crawler installed that will now crawl your link tags and generate your routes when using the command `nuxt export` based on those links.
70+
71+
[Dynamic routes](/guide/routing#dynamic-routes) are ignored by the `generate` command when using Nuxt <= v2.12.
7072

7173
Example:
7274

@@ -201,7 +203,7 @@ async asyncData ({ params, error, payload }) {
201203
- Type: `Boolean`
202204
- Default: `true`
203205

204-
By default, running `nuxt generate` will create a directory for each route & serve an `index.html` file.
206+
By default, running `nuxt export` or `nuxt generate` will create a directory for each route & serve an `index.html` file.
205207

206208
Example:
207209

de/api/context.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ List of all the available keys in `context`:
1212
| `app` | Root Vue Instance | Client & Server | The root Vue instance that includes all your plugins. For example, when using `axios`, you can get access to `$axios` through `context.app.$axios`. |
1313
| `isClient` | `Boolean` | Client & Server | Boolean to let you know if you're actually renderer from the client-side (_deprecated._ use `process.client`). |
1414
| `isServer` | `Boolean` | Client & Server | Boolean to let you know if you're actually renderer from the server-side (_deprecated._ use `process.server`). |
15-
| `isStatic` | `Boolean` | Client & Server | Boolean to let you know if you're actually inside a generated app (via `nuxt generate`). |
15+
| `isStatic` | `Boolean` | Client & Server | Boolean to let you know if you're actually inside a generated app (via `nuxt export` or `nuxt generate`). |
1616
| `isDev` | `Boolean` | Client & Server | Boolean to let you know if you're in dev mode, can be useful for caching some data in production. |
1717
| `isHMR` | `Boolean` | Client & Server | Boolean to let you know if the method/middleware is called from webpack hot module replacement (*only on client-side in dev mode*). |
1818
| `route` | [Vue Router Route](https://router.vuejs.org/en/api/route-object.html) | Client & Server | Vue Router route instance. |
1919
| `store` | [Vuex Store](https://vuex.vuejs.org/en/api.html#vuexstore-instance-properties) | Client & Server | Vuex Store instance. **Available only if the [vuex store](/guide/vuex-store) is set**. |
2020
| `env` | `Object` | Client & Server | Environment variables set in `nuxt.config.js`, see [env api](/api/configuration-env). |
2121
| `params` | `Object` | Client & Server | Alias of `route.params`. |
2222
| `query` | `Object` | Client & Server | Alias of `route.query`. |
23-
| `req` | [`http.Request`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | Server | Request from the Node.js server. If Nuxt is used as a middleware, the req object might be different depending of the framework you're using.<br>**Not available via `nuxt generate`**. |
24-
| `res` | [`http.Response`](https://nodejs.org/api/http.html#http_class_http_serverresponse) | Server | Response from the Node.js server. If Nuxt is used as a middleware, the res object might be different depending of the framework you're using.<br>**Not available via `nuxt generate`**. |
23+
| `req` | [`http.Request`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | Server | Request from the Node.js server. If Nuxt is used as a middleware, the req object might be different depending of the framework you're using.<br>**Not available via `nuxt export` or `nuxt generate`**. |
24+
| `res` | [`http.Response`](https://nodejs.org/api/http.html#http_class_http_serverresponse) | Server | Response from the Node.js server. If Nuxt is used as a middleware, the res object might be different depending of the framework you're using.<br>**Not available via `nuxt export` or `nuxt generate`**. |
2525
| `redirect` | `Function` | Client & Server | Use this method to redirect the user to another route, the status code is used on the server-side, default to `302`. `redirect([status,] path [, query])`. |
2626
| `error` | `Function` | Client & Server | Use this method to show the error page: `error(params)`. The `params` should have the properties `statusCode` and `message`. |
2727
| `nuxtState` | `Object` | Client | Nuxt state, useful for plugins which uses `beforeNuxtRender` to get the nuxt state on client-side before hydration. **Available only in `universal` mode**. |

de/faq/github-pages.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ module.exports = {
5757

5858
and now we just need to set `DEPLOY_ENV='GH_PAGES'` to build the site for GitHub Pages:
5959

60+
For Nuxt >= v2.13
61+
```js
62+
/* package.json */
63+
"scripts": {
64+
"build:gh-pages": "DEPLOY_ENV=GH_PAGES nuxt build",
65+
"generate:gh-pages": "DEPLOY_ENV=GH_PAGES nuxt build && nuxt export"
66+
},
67+
```
68+
For Nuxt <= v2.12
6069
```js
6170
/* package.json */
6271
"scripts": {
@@ -90,6 +99,18 @@ npm install push-dir --save-dev
9099

91100
Add a `deploy` command to your `package.json` with the branch as `gh-pages` for project repository OR `master` for user or organization site.
92101

102+
For Nuxt >= v2.13
103+
```js
104+
"scripts": {
105+
"dev": "nuxt",
106+
"build": "nuxt build",
107+
"start": "nuxt start",
108+
"generate": "nuxt build && nuxt export",
109+
"deploy": "push-dir --dir=dist --branch=gh-pages --cleanup"
110+
},
111+
```
112+
113+
For Nuxt <= v2.12
93114
```js
94115
"scripts": {
95116
"dev": "nuxt",

de/faq/netlify-deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: How to deploy Nuxt.js on Netlify?
77

88
Deploying to [Netlify](https://www.netlify.com) is a low friction option for getting a __statically generated__ Nuxt.js site online quickly.
99

10-
The core of the process leverages the `nuxt generate` command during deployment to build a static version of your Nuxt.js app into a `dist` directory. The contents of this directory are then deployed to a production URL.
10+
The core of the process leverages the `nuxt build && nuxt export`(>= v2.13) or `nuxt generate`(<= v2.12) command during deployment to build a static version of your Nuxt.js app into a `dist` directory. The contents of this directory are then deployed to a production URL.
1111

1212
## Getting Started
1313

@@ -21,6 +21,6 @@ Press the _"New site from Git"_ button on the Netlify dashboard. Authenticate wi
2121

2222
> Optionally, you can add additional ENV variables via the _"Advanced"_ button. These can be helpful for swapping in alternative API credentials and so on. Netlify also provides a [default ENV variables](https://www.netlify.com/docs/build-settings/#build-environment-variables) which can be read by your Nuxt.js application at build time.
2323
24-
Click _"Deploy site"_ to immediately trigger a deploy. Your Netlify site will be assigned a random URL and deployed using the `nuxt generate` command.
24+
Click _"Deploy site"_ to immediately trigger a deploy. Your Netlify site will be assigned a random URL and deployed using the `nuxt build && nuxt export`(>= v2.13) or `nuxt generate`(<= v2.12) command.
2525

2626
Voilà! Your Nuxt.js application is now hosted on Netlify!

de/faq/surge-deployment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ surge dist/
2929

3030
Done :)
3131

32-
If you have a project with [dynamic routes](/guide/routing#dynamic-routes), take a look at the [`generate` configuration](/api/configuration-generate) to tell Nuxt.js how to generate these dynamic routes.
32+
If you have a project with [dynamic routes](/guide/routing#dynamic-routes), take a look at the [`generate` configuration](/api/configuration-generate) to tell Nuxt.js how to generate these dynamic routes if you are using Nuxt <= v2.12.
33+
34+
If you are using Nuxt >= 2.13 then a crawler has been installed tht will crawl your link tags and generate the dynamic routes based on these links when using the command `nuxt build && nuxt export`.
3335

3436
<div class="Alert">
3537

de/guide/commands.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,47 @@ Note: we recommend putting `.nuxt` in `.npmignore` or `.gitignore`.
8888
Nuxt.js gives you the ability to host your web application on any static hosting.
8989

9090
To generate our web application into static files:
91+
For Nuxt >= 2.13:
92+
```json
93+
"scripts": {
94+
"generate": "nuxt build && nuxt export"
95+
}
96+
```
97+
For Nuxt <= 2.12:
98+
```json
99+
"scripts": {
100+
"generate": "nuxt generate"
101+
}
102+
```
103+
91104

92105
```bash
93106
npm run generate
94107
```
95108

96109
It will create a `dist` folder with everything inside ready to be deployed on a static hosting site.
97110

98-
If you have a project with [dynamic routes](/guide/routing#dynamic-routes), take a look at the [generate configuration](/api/configuration-generate) to tell Nuxt.js how to generate these dynamic routes.
111+
<div class="Alert Alert-blue">
112+
113+
As of Nuxt v2.13 there is a crawler installed that will now crawl your link tags and generate your routes when using the command `nuxt build && nuxt export` based on those links.
114+
115+
</div>
116+
117+
<div class="Alert Alert--orange">
118+
119+
**Warning:** dynamic routes are ignored by the `generate` command when using Nuxt <= v2.12: [API Configuration generate](/api/configuration-generate#routes)
120+
121+
</div>
99122

100123
<div class="Alert">
101124

102-
When generating your web application with `nuxt generate`, [the context](/api/context) given to [data()](/guide/async-data#the-data-method) and [fetch()](/guide/vuex-store#the-fetch-method) will not have `req` and `res`.
125+
When generating your web application with `nuxt build && nuxt export` or `nuxt generate`, [the context](/api/context) given to [data()](/guide/async-data#the-data-method) and [fetch()](/guide/vuex-store#the-fetch-method) will not have `req` and `res`.
103126

104127
</div>
105128

106129
### Single Page Application Deployment (SPA)
107130

108-
`nuxt generate` still needs SSR engine during build/generate time while having the advantage of having all our pages pre rendered, and have a high SEO and page load score. The content is generated at *build time*. For example, we can't use it for applications where content depends on user authentication or a real time API (at least for the first load).
131+
`nuxt build && nuxt export` or `nuxt generate` still need the SSR engine during build/generate time while having the advantage of having all our pages pre rendered, and have a high SEO and page load score. The content is generated at *build time*. For example, we can't use it for applications where content depends on user authentication or a real time API (at least for the first load).
109132

110133
The SPA idea is simple! When SPA mode is enabled using `mode: 'spa'` or `--spa` flag, and we run build, generation automatically starts after the build. This generation contains common meta and resource links, but not page content.
111134

de/guide/index.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ If you already have a server, you can plug Nuxt.js by using it as a middleware.
7373

7474
## Static Generated (Pre Rendering)
7575

76-
The big innovation of Nuxt.js comes with the `nuxt generate` command.
76+
The big innovation of Nuxt.js comes with the `nuxt build && nuxt export` command for Nuxt >= v2.13 or `nuxt generate` command for Nuxt <= v2.12.
7777

7878
When building your application, it will generate the HTML for every one of your routes and store it in a file.
7979

@@ -105,15 +105,31 @@ We don't want to manually generate the application every time we update the [doc
105105

106106
1. Clones the [nuxtjs.org repository](https://github.com/nuxt/nuxtjs.org)
107107
2. Installs the dependencies via `npm install`
108-
3. Runs `nuxt generate`
108+
3. Runs `nuxt build && nuxt export`(>= v2.13) or `nuxt generate`(<= v2.12)
109109
4. Pushes the `dist` folder to the `gh-pages` branch
110110

111111
We now have a **Serverless Static Generated Web Application** :)
112112

113-
We can go further by thinking of an e-commerce web application made with `nuxt generate` and hosted on a CDN. Everytime a product is out of stock or back in stock, we regenerate the web app. But if the user navigates through the web app in the meantime, it will be up to date thanks to the API calls made to the e-commerce API. No need to have multiple instances of a server + a cache anymore!
113+
The new full static module which is available since v2.13 generates your html and static assets at build time which means everything is already generated and therefore not only is it great for SEO but it can also be hosted for free on any of the static hosting providers.
114+
115+
Nuxt v2.13 also comes with a crawler installed which will crawl your link tags and generate your dynamic routes based on these links which means there is no need to manually generate your dynamic links anymore.
116+
117+
The static target works by saving the calls to your API in payload.js files in a static folder. These payloads are then cached for better performance and offline support and as your API is not called on client side navigation any more (when called using asyncData and fetch), it also means you do not have to expose your API to the public.
118+
119+
When your site is generated your html is generated with all it's content and on client side navigation these pages are reconstructed using the payload files for your API data. By separating the code from the content you can easily re-generate your content without the need to re-build your whole site. That means once your site is built and you only want to change your content you can simply call `nuxt export` which will re-generate your content only, and as the content doesn't need to go through webpack it means content regeneration is lightening fast.
120+
121+
If you want to generate static sties, using Nuxt >= v2.13, you will need to add `static` as the `target` in your nuxt.config file. The default value for `target` is `server`.
122+
123+
`nuxt.config.js`
124+
```js
125+
export default {
126+
target: 'static'
127+
}
128+
```
129+
To learn more about the new static target checkout our [article](/blog/going-full-static)
114130

115131
<div class="Alert">
116132

117-
See [How to deploy on GitHub Pages?](/faq/github-pages) for more details on how to deploy to GitHub Pages.
133+
See [How to deploy on Netlify?](/faq/netlify-deployment) for more details on how to deploy to Netlify.
118134

119135
</div>

de/guide/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ module.exports = function () {
303303

304304
// Add hook for generate
305305
this.nuxt.hook('generate', async (generator) => {
306-
// This will be called when a Nuxt generate starts
306+
// This will be called when a Nuxt starts
307307
})
308308
}
309309
```

de/guide/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ Vue.use(VueNotifications)
149149

150150
In case you need to require some libraries only for the server, you can use the `process.server` variable set to `true` when webpack is creating the `server.bundle.js` file.
151151

152-
Also, if you need to know if you are inside a generated app (via `nuxt generate`), you can check `process.static`, set to `true` during generation and after. To know the state when a page is being server-rendered by `nuxt generate` before being saved, you can use `process.static && process.server`.
152+
Also, if you need to know if you are inside a generated app (via `nuxt export` or `nuxt generate`), you can check `process.static`, set to `true` during generation and after. To know the state when a page is being server-rendered by `nuxt build && nuxt export` or `nuxt generate` before being saved, you can use `process.static && process.server`.

0 commit comments

Comments
 (0)