From 8253f5e75bff05a9583540e889461b2ac1879f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 1 Mar 2017 17:54:44 +0100 Subject: [PATCH] Add plugin ssr option & rename process.browser --- TODO.md | 17 ++++++++ examples/plugins-vendor/nuxt.config.js | 3 +- examples/plugins-vendor/pages/index.vue | 2 +- .../plugins/vue-notifications.js | 39 +++++++++---------- lib/app/App.vue | 2 +- lib/app/index.js | 14 +++++-- lib/app/router.js | 2 +- lib/build.js | 7 +++- 8 files changed, 57 insertions(+), 29 deletions(-) diff --git a/TODO.md b/TODO.md index 475654d31d..695af7a08b 100644 --- a/TODO.md +++ b/TODO.md @@ -17,3 +17,20 @@ Release: ## Deprecated - `process.BROWSER_BUILD` is deprecated in favour of `process.browser` (`BROWSER_BUILD` will be removed for the 1.0) - `process.SERVER_BUILD` is deprecated in favour of `process.server` (`SERVER_BUILD` will be removed for the 1.0) + +## Define `plugins` only for client-side + +Some Vue plugins might only work for client-side, you can now use an `Object` instead of a string to use a plugin only for client-side: + +`nuxt.config.js` +```js +module.exports = { + plugins: [ + '~plugins/client-and-server.js', + { + src: '~plugins/only-client-side.js', + ssr: false // disable for server-side + } + ] +} +``` diff --git a/examples/plugins-vendor/nuxt.config.js b/examples/plugins-vendor/nuxt.config.js index 61389f23e5..76d693a3a1 100644 --- a/examples/plugins-vendor/nuxt.config.js +++ b/examples/plugins-vendor/nuxt.config.js @@ -3,6 +3,7 @@ module.exports = { vendor: ['axios', 'mini-toastr', 'vue-notifications'] }, plugins: [ - '~plugins/vue-notifications.js' + // ssr: false to only include it on client-side + { src: '~plugins/vue-notifications.js', ssr: false } ] } diff --git a/examples/plugins-vendor/pages/index.vue b/examples/plugins-vendor/pages/index.vue index d32a12873f..4113897d1b 100644 --- a/examples/plugins-vendor/pages/index.vue +++ b/examples/plugins-vendor/pages/index.vue @@ -7,7 +7,7 @@