examples: Use process.server instead of isServer

This commit is contained in:
Sébastien Chopin 2017-10-28 17:20:11 +02:00
parent 262bffc35d
commit 23e1c3fd06
5 changed files with 9 additions and 9 deletions

View File

@ -7,8 +7,8 @@ module.exports = {
app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js
}, },
vendor: ['lodash'], vendor: ['lodash'],
extend (config, { dev }) { extend (config, { isDev }) {
if (dev) { if (isDev) {
config.devtool = 'eval-source-map' config.devtool = 'eval-source-map'
} }
const urlLoader = config.module.rules.find((loader) => loader.loader === 'url-loader') const urlLoader = config.module.rules.find((loader) => loader.loader === 'url-loader')

View File

@ -3,7 +3,7 @@ import VueI18n from 'vue-i18n'
Vue.use(VueI18n) Vue.use(VueI18n)
export default ({ app, isClient, store }) => { export default ({ app, store }) => {
// Set i18n instance on app // Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch // This way we can use it in middleware and pages asyncData/fetch
app.i18n = new VueI18n({ app.i18n = new VueI18n({

View File

@ -7,9 +7,9 @@
<script> <script>
export default { export default {
asyncData ({ isServer }) { asyncData () {
return { return {
name: (isServer ? 'server' : 'client') name: (process.server ? 'server' : 'client')
} }
} }
} }

View File

@ -11,14 +11,14 @@ export const getCookies = (str) => {
** Executed by ~/.nuxt/index.js with context given ** Executed by ~/.nuxt/index.js with context given
** This method can be asynchronous ** This method can be asynchronous
*/ */
export default ({ isServer, req }, inject) => { export default ({ req }, inject) => {
// Inject `cookies` key // Inject `cookies` key
// -> app.$cookies // -> app.$cookies
// -> this.$cookies in vue components // -> this.$cookies in vue components
// -> this.$cookies in store actions/mutations // -> this.$cookies in store actions/mutations
inject('cookies', new Vue({ inject('cookies', new Vue({
data: () => ({ data: () => ({
cookies: getCookies(isServer ? req.headers.cookie : document.cookie) cookies: getCookies(process.server ? req.headers.cookie : document.cookie)
}), }),
methods: { methods: {
set(...args) { set(...args) {

View File

@ -7,9 +7,9 @@
<script> <script>
export default { export default {
asyncData ({ req, isServer }) { asyncData () {
return { return {
name: req ? 'server' : 'client' name: process.server ? 'server' : 'client'
} }
} }
} }