diff --git a/de/api/configuration-dev.md b/de/api/configuration-dev.md index 744091cfb..6029fa990 100644 --- a/de/api/configuration-dev.md +++ b/de/api/configuration-dev.md @@ -42,15 +42,11 @@ app.use(nuxt.render) // Build only in dev mode if (config.dev) { new Builder(nuxt).build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server app.listen(port, '0.0.0.0').then(() => { - nuxt.showOpen() + console.log(`Server is listening on port: ${port}`) }) ``` diff --git a/de/api/nuxt-render.md b/de/api/nuxt-render.md index 223b44fac..10f2d9db1 100644 --- a/de/api/nuxt-render.md +++ b/de/api/nuxt-render.md @@ -34,10 +34,6 @@ app.use(nuxt.render) if (config.dev) { new Builder(nuxt).build() .then(listen) - .catch((error) => { - console.error(error) - process.exit(1) - }) } else { listen() diff --git a/en/api/configuration-build.md b/en/api/configuration-build.md index a1ae9e16c..b91e9ceb6 100644 --- a/en/api/configuration-build.md +++ b/en/api/configuration-build.md @@ -68,6 +68,15 @@ export default { > Enable cache of [terser-webpack-plugin ](https://github.com/webpack-contrib/terser-webpack-plugin#options) and [cache-loader](https://github.com/webpack-contrib/cache-loader#cache-loader) +## crossorigin + +- Type: `String` +- Default: `undefined` + + Configure the `crossorigin` attribute on `` and ` ``` +Conversely, you can manually set `scrollToTop` to `false` on parent routes as well. + If you want to overwrite the default scroll behavior of Nuxt.js, take a look at the [scrollBehavior option](/api/configuration-router#scrollBehavior). diff --git a/en/guide/plugins.md b/en/guide/plugins.md index 9768bf6a1..8a353138f 100644 --- a/en/guide/plugins.md +++ b/en/guide/plugins.md @@ -197,7 +197,6 @@ export const actions = { ``` - ## Client-side only Some plugins might work **only in the browser** because they lack SSR support. @@ -229,3 +228,36 @@ In case you need to import some libraries in a plugin only on *server-side*, you Also, if you need to know if you are inside a generated app (via `nuxt generate`), you can check if `process.static` is set to `true`. This is only the case during and after the generation. You can also combine both options to hit the spot when a page is being server-rendered by `nuxt generate` before being saved (`process.static && process.server`). + +**Note**: Since Nuxt.js 2.4, `mode` has been introduced as option of `plugins` to specify plugin type, possible value are: `client` or `server`. `ssr: false` will be adapted to `mode: 'client'` and deprecated in next major release. + +Example: + +`nuxt.config.js`: + +```js +export default { + plugins: [ + { src: '~/plugins/both-sides.js' }, + { src: '~/plugins/client-only.js', mode: 'client' }, + { src: '~/plugins/server-only.js', mode: 'server' } + ] +} +``` + +### Name conventional plugin + +If plugin is assumed to be run only in client or server side, `.client.js` or `.server.js` can be applied as extension of plugin file, the file will be automatically included in corresponding side. + +Example: + +`nuxt.config.js`: + +```js +export default { + plugins: [ + '~/plugins/foo.client.js', // only in client side + '~/plugins/bar.server.js', // only in server side + '~/plugins/baz.js' // both client & server + ] +} diff --git a/es/api/configuration-dev.md b/es/api/configuration-dev.md index e75455ba7..5a9766a91 100644 --- a/es/api/configuration-dev.md +++ b/es/api/configuration-dev.md @@ -40,10 +40,6 @@ app.use(nuxt.render) // Build only in dev mode if (config.dev) { nuxt.build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server diff --git a/es/api/nuxt-render.md b/es/api/nuxt-render.md index 4e80a4c7a..f43362f88 100644 --- a/es/api/nuxt-render.md +++ b/es/api/nuxt-render.md @@ -31,10 +31,6 @@ app.use(nuxt.render) // Build only in dev mode with hot-reloading if (config.dev) { nuxt.build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server diff --git a/fr/api/configuration-dev.md b/fr/api/configuration-dev.md index 6395bbed5..073be564c 100644 --- a/fr/api/configuration-dev.md +++ b/fr/api/configuration-dev.md @@ -42,15 +42,11 @@ app.use(nuxt.render) // Build seulement en mode dev if (config.dev) { new Builder(nuxt).build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Écouter le serveur app.listen(port, '0.0.0.0').then(() => { - nuxt.showOpen() + console.log(`Server is listening on port: ${port}`) }) ``` diff --git a/fr/api/nuxt-render.md b/fr/api/nuxt-render.md index 80733d919..642cd584a 100644 --- a/fr/api/nuxt-render.md +++ b/fr/api/nuxt-render.md @@ -34,10 +34,6 @@ app.use(nuxt.render) if (config.dev) { new Builder(nuxt).build() .then(listen) - .catch((error) => { - console.error(error) - process.exit(1) - }) } else { listen() diff --git a/id/api/configuration-dev.md b/id/api/configuration-dev.md index 1cabb34ca..58cdc0fa4 100644 --- a/id/api/configuration-dev.md +++ b/id/api/configuration-dev.md @@ -42,15 +42,11 @@ app.use(nuxt.render) // Build only in dev mode if (config.dev) { new Builder(nuxt).build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server app.listen(port, '0.0.0.0').then(() => { - nuxt.showOpen() + console.log(`Server is listening on port: ${port}`) }) ``` diff --git a/id/api/nuxt-render.md b/id/api/nuxt-render.md index a75de0946..3be21ac98 100644 --- a/id/api/nuxt-render.md +++ b/id/api/nuxt-render.md @@ -35,10 +35,6 @@ app.use(nuxt.render) if (config.dev) { new Builder(nuxt).build() .then(listen) - .catch((error) => { - console.error(error) - process.exit(1) - }) } else { listen() diff --git a/ja/api/configuration-dev.md b/ja/api/configuration-dev.md index d1c2be41c..539bade8b 100644 --- a/ja/api/configuration-dev.md +++ b/ja/api/configuration-dev.md @@ -42,15 +42,11 @@ app.use(nuxt.render) // 開発モードのときのみビルドする if (config.dev) { new Builder(nuxt).build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // サーバーを Listen する app.listen(port, '0.0.0.0').then(() => { - nuxt.showOpen() + console.log(`Server is listening on port: ${port}`) }) ``` diff --git a/ja/api/nuxt-render.md b/ja/api/nuxt-render.md index 81ebf2ada..49f6236a4 100644 --- a/ja/api/nuxt-render.md +++ b/ja/api/nuxt-render.md @@ -34,10 +34,6 @@ app.use(nuxt.render) if (config.dev) { new Builder(nuxt).build() .then(listen) - .catch((error) => { - console.error(error) - process.exit(1) - }) } else { listen() diff --git a/ko/api/configuration-dev.md b/ko/api/configuration-dev.md index 8e76b405d..fc9faf009 100644 --- a/ko/api/configuration-dev.md +++ b/ko/api/configuration-dev.md @@ -39,10 +39,6 @@ app.use(nuxt.render) // 개발 모드에서만 사용되는 빌드입니다. if (config.dev) { nuxt.build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server diff --git a/ko/api/nuxt-render.md b/ko/api/nuxt-render.md index 529803947..ead2f2983 100644 --- a/ko/api/nuxt-render.md +++ b/ko/api/nuxt-render.md @@ -31,10 +31,6 @@ app.use(nuxt.render) // dev 모드를 위해 핫-로딩 빌드를 합니다. if (config.dev) { nuxt.build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // 서버 diff --git a/pt-BR/api/configuration-dev.md b/pt-BR/api/configuration-dev.md index 2ba9234fd..9ace1a5f1 100644 --- a/pt-BR/api/configuration-dev.md +++ b/pt-BR/api/configuration-dev.md @@ -40,15 +40,11 @@ app.use(nuxt.render) // Build only in dev mode if (config.dev) { new Builder(nuxt).build() - .catch((error) => { - console.error(error) - process.exit(1) - }) } // Listen the server app.listen(port, '0.0.0.0').then(() => { - nuxt.showOpen() + console.log(`Server is listening on port: ${port}`) }) ``` diff --git a/pt-BR/api/nuxt-render.md b/pt-BR/api/nuxt-render.md index 223b44fac..10f2d9db1 100644 --- a/pt-BR/api/nuxt-render.md +++ b/pt-BR/api/nuxt-render.md @@ -34,10 +34,6 @@ app.use(nuxt.render) if (config.dev) { new Builder(nuxt).build() .then(listen) - .catch((error) => { - console.error(error) - process.exit(1) - }) } else { listen() diff --git a/ru/api/configuration-build.md b/ru/api/configuration-build.md index 107fff527..64550b8b2 100644 --- a/ru/api/configuration-build.md +++ b/ru/api/configuration-build.md @@ -81,6 +81,33 @@ export default { Смотри [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) для доступных вариантов. +## extend + +- Тип: `Function` + +> Позволяет вручную расширить конфигурацию webpack для клиентских и серверных пакетов. + +Функция вызывается дважды, один раз для серверной сборки и один раз для клиентской. Аргументы метода: + +1. Конфигурационный объект Webpack +2. Объект со следующими ключами (все логические, кроме `loaders`):` isDev`, `isClient`,` isServer` + +Пример (`nuxt.config.js`): +```js +module.exports = { + build: { + extend (config, { isClient }) { + // Расширить конфигурацию webpack только для клиентской сборки + if (isClient) { + config.devtool = 'eval-source-map' + } + } + } +} +``` + +Если вы хотите узнать больше о нашей конфигурации webpack по умолчанию, взгляните на наш [каталог webpack](https://github.com/nuxt/nuxt.js/tree/dev/packages/webpack/src/config). + ## build.vendor > Nuxt.js позволяет добавлять модули в генерируемый файл `vendor.bundle.js`, чтобы уменьшить размер финального приложения. Это действительно полезно при использовании внешних модулей (например, `axios`). diff --git a/zh/api/configuration-build.md b/zh/api/configuration-build.md index 6f637d92e..822f1c2d1 100644 --- a/zh/api/configuration-build.md +++ b/zh/api/configuration-build.md @@ -66,6 +66,15 @@ module.exports = { > 启用 [uglifyjs-webpack-plugin ](https://github.com/webpack-contrib/uglifyjs-webpack-plugin#options) 和 [cache-loader](https://github.com/webpack-contrib/cache-loader#cache-loader) 的缓存 +## crossorigin + +- 类型: `String` +- 默认: `undefined` + +在生成的HTML中的``和`