Skip to content

Commit 133f3e8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into working
# Conflicts: # en/api/configuration-build.md # en/api/configuration-generate.md # en/api/context.md # en/api/nuxt-render-and-get-window.md # en/guide/assets.md Signed-off-by: MachinisteWeb <[email protected]>
2 parents af24584 + f59fb93 commit 133f3e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1482
-306
lines changed

en/api/components-no-ssr.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "API: The <no-ssr> Component"
3+
description: Skip component rendering on server side(rendering), and display placeholder text.
4+
---
5+
6+
# The &lt;no-ssr&gt; Component
7+
8+
> This component is used to purposely remove the component from the subject of server side rendering.
9+
10+
**Props**:
11+
- placeholder: `String`
12+
- This prop will be used as a content of inner `div` and displayed as text only on server side rendering.
13+
14+
```html
15+
<template>
16+
<div>
17+
<ssrfrendly-component />
18+
<no-ssr>
19+
<not-ssrfrendly />
20+
</no-ssr>
21+
</div>
22+
</template>
23+
```
24+
25+
<p style="width: 294px;position: fixed; top : 64px; right: 4px;" class="Alert Alert--orange"><strong>⚠Cette page est actuellement en cours de traduction française. Vous pouvez repasser plus tard ou <a href="https://github.com/vuejs-fr/nuxt" target="_blank">participer à la traduction</a> de celle-ci dès maintenant !</strong></p><p>This component is a clone of [egoist/vue-no-ssr](https://github.com/egoist/vue-no-ssr).
26+
Thanks [@egoist](https://github.com/egoist)!</p>

en/api/configuration-build.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ description: Nuxt.js vous permet de personnaliser la configuration webpack pour
99
1010
## analyze
1111

12-
> Nuxt.js utilise [webpack-bundle-analyzer](https://github.com/th0r/webpack-bundle-analyzer) pour vous permettre de visualiser vos paquetages (« bundles ») et comment les optimiser.
12+
> Nuxt.js utilise [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyze) pour vous permettre de visualiser vos paquetages (« bundles ») et les optimiser.
1313
1414
- Type : `Boolean` ou `Object`
1515
- Par défaut : `false`
1616

17-
Si c'est un objet, consultez les propriétés disponibles [ici](https://github.com/th0r/webpack-bundle-analyzer#as-plugin).
17+
Si c'est un objet, consultez les propriétés disponibles [ici](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin).
1818

1919
Exemple (`nuxt.config.js`) :
2020

@@ -79,7 +79,7 @@ Voir [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware)
7979
`extend` est appelé deux fois, une fois pour le paquetage serveur et une fois pour le paquetage client. Les arguments de la méthode sont :
8080

8181
1. l'objet de configuration webpack,
82-
2. un objet avec les propriétés suivantes (toutes booléennes): `dev`, `isClient`, `isServer`.
82+
2. un objet avec les propriétés suivantes (toutes booléennes): `isDev`, `isClient`, `isServer`.
8383

8484
Exemple (`nuxt.config.js`) :
8585

@@ -253,15 +253,15 @@ Exemple (`nuxt.config.js`) :
253253
```js
254254
module.exports = {
255255
build: {
256-
templates: [
257-
{
258-
src: '~/modules/support/plugin.js', // `src` peut être absolue ou relatif
259-
dst: 'support.js', // `dst` est relatif au dossier de `.nuxt`
260-
options: { // Les options sont fournies au templases par la propriété `options`
261-
live_chat: false
262-
}
263-
}
264-
]
256+
templates: [
257+
{
258+
src: '~/modules/support/plugin.js', // `src` peut être absolue ou relatif
259+
dst: 'support.js', // `dst` est relatif au dossier de `.nuxt`
260+
options: { // Les options sont fournies au templases par la propriété `options`
261+
live_chat: false
262+
}
263+
}
264+
]
265265
}
266266
}
267267
```
@@ -306,9 +306,9 @@ module.exports = {
306306
```js
307307
module.exports = {
308308
build: {
309-
watch: [
310-
'~/.nuxt/support.js'
311-
]
309+
watch: [
310+
'~/.nuxt/support.js'
311+
]
312312
}
313313
}
314314
```

en/api/configuration-generate.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Quand vous lancez `nuxt generate` ou appelez `nuxt.generate()`, Nuxt.js utiliser
1818

1919
Nom du répertoire créé par `nuxt generate`.
2020

21+
## fallback
22+
23+
- Type: `String` or `Boolean`
24+
- Default: `'200.html'`
25+
26+
The path to the SPA fallback. This file can be used when doing deploys of generated sites to static hosting. It falls back to `mode: 'spa'` when a route isn't generated.
27+
2128
## interval
2229

2330
- Type : `Number`
@@ -33,7 +40,7 @@ Interval entre 2 rendus pour éviter d'inonder les appels d'API effectués par u
3340
```js
3441
minify: {
3542
collapseBooleanAttributes: true,
36-
collapseWhitespace: true,
43+
collapseWhitespace: false,
3744
decodeEntities: true,
3845
minifyCSS: true,
3946
minifyJS: true,
@@ -47,7 +54,7 @@ minify: {
4754
removeStyleLinkTypeAttributes: false,
4855
removeTagWhitespace: false,
4956
sortAttributes: true,
50-
sortClassName: true,
57+
sortClassName: false,
5158
trimCustomFragments: true,
5259
useShortDoctype: true
5360
}

en/api/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Liste de toutes les propriétés disponibles dans `context` :
2323
| `req` | [`http.Request`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | Serveur | Requête faite au serveur Node.js. Si Nuxt est utilisé en tant que middleware, l'objet `req` peut être différent en fonction du framework utilisé.<br>**Non disponible avec `nuxt generate`**. |
2424
| `res` | [`http.Response`](https://nodejs.org/api/http.html#http_class_http_serverresponse) | Serveur | Réponse faite par le serveur Node.js. Si Nuxt est utilisé en tant que middleware, l'objet `res` peut être différent en fonction du framework utilisé.<br>**Non disponible avec `nuxt generate`**. |
2525
| `redirect` | `Function` | Client et serveur | Cette méthode redirige l'utilisateur vers une autre route, un code de statut est utilisé côté serveur, par défaut c'est le `302`. `redirect([status,] path [, query])`. |
26-
| `error` | `Function` | Client et serveur | Cette méthode montre la page d'erreur : `error(params)`. L'objet `params` devrait avoir les propriétés `statusCode` et `message`. |
26+
| `error` | `Function` | Client et serveur | Cette méthode montre la page d'erreur : `error(params)`. L'objet `params` devrait avoir les propriétés `statusCode` et `message`. |
2727
| `nuxtState` | `Object` | Client | L'état de Nuxt, utile pour les plugins qui utilisent `beforeNuxtRender` pour connaitre l'état de Nuxt côté client avant l'hydratation. **Disponible seulement en mode `universal`**. |
2828
| `beforeNuxtRender(fn)` | `Function` | Serveur | Cette méthode met à jour la variable `__NUXT__` rendue côté client, la fonction `fn` (pouvant être asynchrone) est appelée avec `{ Components, nuxtState }`, voir cet [exemple](https://github.com/nuxt/nuxt.js/blob/cf6b0df45f678c5ac35535d49710c606ab34787d/test/fixtures/basic/pages/special-state.vue). |

en/api/menu.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"links": [
3131
{ "name": "nuxt", "to": "/components-nuxt" },
3232
{ "name": "nuxt-child", "to": "/components-nuxt-child" },
33-
{ "name": "nuxt-link", "to": "/components-nuxt-link" }
33+
{ "name": "nuxt-link", "to": "/components-nuxt-link" },
34+
{ "name": "no-ssr", "to": "/components-no-ssr" }
3435
]
3536
},
3637
{

en/guide/routing.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,52 @@ router: {
211211
}
212212
```
213213

214+
### SPA fallback
215+
216+
You can enable SPA fallbacks for dynamic routes too. Nuxt.js will output an extra file that is the same as the index.html that would be used in `mode: 'spa'`. Most static hosting services can be configured to to use the SPA template if no file matches. It won't include the `head` info or any HTML, but it will still resolve and load the data from the API.
217+
218+
We enable this in our `nuxt.config.js` file:
219+
220+
``` js
221+
module.exports = {
222+
generate: {
223+
fallback: true, // if you want to use '404.html'
224+
fallback: 'my-fallback/file.html' // if your hosting needs a custom location
225+
}
226+
}
227+
```
228+
229+
#### Implementation for Surge
230+
231+
Surge [can handle](https://surge.sh/help/adding-a-custom-404-not-found-page) both `200.html` and `404.html`. `generate.fallback` is set to `200.html` by default, so no need to change it.
232+
233+
#### Implementation for GitHub Pages and Netlify
234+
235+
GitHub Pages and Netlify recognize the `404.html` file automatically, so setting `generate.fallback` to `true` is all we have to do!
236+
237+
#### Implementation for Firebase Hosting
238+
239+
To use on Firebase Hosting, configure `generate.fallback` to `true` and use the following config ([more info](https://firebase.google.com/docs/hosting/url-redirects-rewrites#section-rewrites)):
240+
241+
``` json
242+
{
243+
"hosting": {
244+
"public": "dist",
245+
"ignore": [
246+
"firebase.json",
247+
"**/.*",
248+
"**/node_modules/**"
249+
],
250+
"rewrites": [
251+
{
252+
"source": "**",
253+
"destination": "/404.html"
254+
}
255+
]
256+
}
257+
}
258+
```
259+
214260
## Transitions
215261

216262
Nuxt.js utilise le composant [`<transition>`](http://vuejs.org/v2/guide/transitions.html#Transitioning-Single-Elements-Components) afin de vous permettre de créer de superbes transitions / animations entre vos routes.

es/api/configuration-build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = {
6464
The extend is called twice, one time for the server bundle, and one time for the client bundle. The arguments of the method are:
6565

6666
1. Webpack config object
67-
2. Object with the folowing keys (all boolean): `dev`, `isClient`, `isServer`
67+
2. Object with the folowing keys (all boolean): `isDev`, `isClient`, `isServer`
6868

6969
Example (`nuxt.config.js`):
7070
```js
@@ -80,7 +80,7 @@ module.exports = {
8080
}
8181
```
8282

83-
If you want to see more about our default webpack configuration, take a look at our [webpack directory](https://github.com/nuxt/nuxt.js/tree/master/lib/webpack).
83+
If you want to see more about our default webpack configuration, take a look at our [webpack directory](https://github.com/nuxt/nuxt.js/tree/master/lib/builder/webpack).
8484

8585
## filenames
8686

es/api/configuration-generate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Interval between 2 render to avoid flooding the API calls made to a potential AP
3333
```js
3434
minify: {
3535
collapseBooleanAttributes: true,
36-
collapseWhitespace: true,
36+
collapseWhitespace: false,
3737
decodeEntities: true,
3838
minifyCSS: true,
3939
minifyJS: true,
@@ -47,7 +47,7 @@ minify: {
4747
removeStyleLinkTypeAttributes: false,
4848
removeTagWhitespace: false,
4949
sortAttributes: true,
50-
sortClassName: true,
50+
sortClassName: false,
5151
trimCustomFragments: true,
5252
useShortDoctype: true
5353
}

es/guide/development-tools.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,48 +113,67 @@ npm test
113113

114114
jsdom has some limitations because it does not use a browser. However, it will cover most of our tests. If you want to use a browser to test your application, you might want to check out [Nightwatch.js](http://nightwatchjs.org).
115115

116-
## ESLint
116+
## ESLint && Prettier
117117

118-
> ESLint is a great tool to keep your code clean
118+
> [ESLint](http://eslint.org) is a great tool to keep your code clean
119119
120-
You can add [ESLint](http://eslint.org) pretty easily with nuxt.js, first, you need to add the npm dependencies:
120+
> [Prettier](prettier.io) is a very popular code formatter
121+
122+
You can add ESLint with Prettier pretty easily with nuxt.js, first, you need to add the npm dependencies:
121123

122124
```bash
123-
npm install --save-dev babel-eslint eslint eslint-config-standard eslint-plugin-html eslint-plugin-promise eslint-plugin-standard eslint-plugin-import eslint-plugin-node
125+
npm install --save-dev babel-eslint eslint eslint-config-prettier eslint-loader eslint-plugin-vue eslint-plugin-prettier prettier
124126
```
125127

126128
Then, you can configure ESLint via a `.eslintrc.js` file in your root project directory:
127129
```js
128130
module.exports = {
129131
root: true,
130-
parser: 'babel-eslint',
131132
env: {
132133
browser: true,
133134
node: true
134135
},
135-
extends: 'standard',
136+
parserOptions: {
137+
parser: 'babel-eslint'
138+
},
139+
extends: [
140+
"eslint:recommended",
141+
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
142+
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
143+
"plugin:vue/recommended",
144+
"plugin:prettier/recommended"
145+
],
136146
// required to lint *.vue files
137147
plugins: [
138-
'html'
148+
'vue'
139149
],
140150
// add your custom rules here
141-
rules: {},
142-
globals: {}
151+
rules: {
152+
"semi": [2, "never"],
153+
"no-console": "off",
154+
"vue/max-attributes-per-line": "off",
155+
"prettier/prettier": ["error", { "semi": false }]
156+
}
143157
}
144158
```
145159

146-
Then, you can add a `lint` script in your `package.json`:
160+
Then, you can add a `lint` and`lintfix` scripts in your `package.json`:
147161

148162
```js
149163
"scripts": {
150-
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
164+
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
165+
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
151166
}
152167
```
153168

154-
You can now launch:
169+
You can now launch `lint` to just check for errors:
155170
```bash
156171
npm run lint
157172
```
173+
or `lintfix` to also fix those which are doable
174+
```bash
175+
npm run lintfix
176+
```
158177

159178
ESLint will lint every of your JavaScript and Vue files while ignoring your ignored files defined in your `.gitignore`.
160179

fr/api/configuration-build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Voir [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware)
7979
`extend` est appelé deux fois, une fois pour le paquetage serveur et une fois pour le paquetage client. Les arguments de la méthode sont :
8080

8181
1. l'objet de configuration webpack,
82-
2. un objet avec les propriétés suivantes (toutes booléennes): `dev`, `isClient`, `isServer`.
82+
2. un objet avec les propriétés suivantes (toutes booléennes): `isDev`, `isClient`, `isServer`.
8383

8484
Exemple (`nuxt.config.js`) :
8585

@@ -96,7 +96,7 @@ module.exports = {
9696
}
9797
```
9898

99-
Si vous voulez en savoir plus à propos de notre configuration webpack par défaut, consultez [le répertoire webpack](https://github.com/nuxt/nuxt.js/tree/master/lib/webpack).
99+
Si vous voulez en savoir plus à propos de notre configuration webpack par défaut, consultez [le répertoire webpack](https://github.com/nuxt/nuxt.js/tree/master/lib/builder/webpack).
100100

101101
## extractCSS
102102

0 commit comments

Comments
 (0)