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
},
vendor: ['lodash'],
extend (config, { dev }) {
if (dev) {
extend (config, { isDev }) {
if (isDev) {
config.devtool = 'eval-source-map'
}
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)
export default ({ app, isClient, store }) => {
export default ({ app, store }) => {
// Set i18n instance on app
// This way we can use it in middleware and pages asyncData/fetch
app.i18n = new VueI18n({

View File

@ -7,9 +7,9 @@
<script>
export default {
asyncData ({ isServer }) {
asyncData () {
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
** This method can be asynchronous
*/
export default ({ isServer, req }, inject) => {
export default ({ req }, inject) => {
// Inject `cookies` key
// -> app.$cookies
// -> this.$cookies in vue components
// -> this.$cookies in store actions/mutations
inject('cookies', new Vue({
data: () => ({
cookies: getCookies(isServer ? req.headers.cookie : document.cookie)
cookies: getCookies(process.server ? req.headers.cookie : document.cookie)
}),
methods: {
set(...args) {

View File

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