M
M
Martovitskiy2017-10-22 10:17:28
JavaScript
Martovitskiy, 2017-10-22 10:17:28

How to defeat window is not defined in a plug-in?

Help? please correctly defeat the error.
nuxt.config.js

module.exports = {
  plugins: {
     '~plugins/fullpage-vue.js'
  },
build: {
    vendor: [
      'fullpage-vue'
    ]
   ...
}

fullpage-vue.js
import Vue from 'vue'
import VueFullpage from 'fullpage-vue'

if (process.BROWSER_BUILD) {
  Vue.use(VueFullpage)
}

That doesn't help. I get error window is not defined node_modules\fullpage-vue\dist\fullpage.js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2018-01-20
@Martovitskiy

In Nuxt, plugins are processed on both the server and the client, but since there is no window object on the server, you need to tell nuxt that this plugin should not be used with SSR

module.exports = {
  plugins: [
    // ssr: false to only include it on client-side
    { src:  '~plugins/fullpage-vue.js', ssr: false }
  ],
build: {
    vendor: [
      'fullpage-vue'
    ]
   ...
}

Source: https://nuxtjs.org/examples/plugins

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question