title: Nuxt.js run generate, global mixin (... is not a function)
body: <p>I have made some global mixes and they work fine as long as I make <code>run dev</code> command.
  But when I make <code>run generate</code> I get an error in the console &quot;is not a function&quot;.
  Similar problems appear on the server when I connect external plugins, but do not happen in development mode.
  I have tried different solutions but nothing helped.</p>
  <p>Here is my nuxt.config (left only basic settings for demo). Pay attention to <code>plugins/seo.js</code></p>
  <pre class="lang-js prettyprint-override"><code>export default {
    target: 'static',
    srcDir: 'nuxt',
    ssr: false,
    plugins: [
      { src: '~plugins/nuxt-quill-plugin', ssr: false },
      { src:'~plugins/vue-final-modal.js'},
      { src: '~plugins/notifications.js', mode: 'client' },
      '~plugins/persistedState.js',
      '~plugins/clickOutside.js',
      '~plugins/dateTimePicker.js',
      '~plugins/seo.js',
      &quot;~plugins/location.js&quot;,
      &quot;~plugins/fetchData.js&quot;
    ],
    echo: {
       plugins: [ '~/plugins/echo.js' ]
    },
    components: true,
    modules: [
      '@nuxtjs/axios',
      '@nuxtjs/pwa',
      '@nuxtjs/auth-next',
      ['@nuxtjs/laravel-echo', { 
        broadcaster: 'pusher', 
        key: 'e27d2f2173c11d7b12c7',
        cluster: 'eu',
        forceTLS: true,
        authEndpoint: '/broadcasting/auth',
      }],
        'nuxt-laravel'
    ],
    build: {
     transpile: [&quot;vue-final-modal&quot;, 'notifications', 'fetchData', 'location', 'seo', 'dom7'],
     vendor: [&quot;vue-final-modal&quot;, 'notifications', 'fetchData', 'location', 'seo', 'dom7'],
      loaders: {
          cssModules: {
              localIdentName: '[local]', //Work
              modules: false
          },
          css: {
              localIdentName: '[local]'
          }
      }
    },
    generate: {
      vendor: [&quot;vue-final-modal&quot;, 'notifications', 'nuxt-quill-plugin', 'fetchData', 'location', 'seo', 'dom7'],
      transpile: [&quot;vue-final-modal&quot;, 'notifications', 'nuxt-quill-plugin', 'fetchData', 'location', 'seo', 'dom7'],
      loaders: {
          cssModules: {
              localIdentName: '[local]', //Work
              modules: false
          },
          css: {
              localIdentName: '[local]'
          }
      }       
  },
  }
  </code></pre>
  <p>And here is one of my mixins that breaks with the error &quot;seoPath is not a function&quot;. Pay attention to <code>seoPath</code> method.</p>
  <pre class="lang-js prettyprint-override"><code>import Vue from &quot;vue&quot;
  
  if (!Vue.seo_dispatcher) {
    Vue.seo_dispatcher = true
    
    Vue.mixin({
          head() {
              return {
                  title: this.seoTitle,
                  meta: [
                      {
                          hid: 'description',
                          name: 'description',
                          content: this.seoDesc
                      },{
                          hid: 'title',
                          name: 'title',
                          content: this.seoTitle
                      }
                  ]
              }
          },
          data(){
              return {
                  variableAliases: {
                      '#CITY#': 'city',
                      '#CITY_PRED#': 'city',
                      '#CITY_REGION#': 'region',
                      '#CITY_REGION_PRED#': 'region',
                      '#NAME#': 'seo',
                      '#MIN.PRICE#': 'min_price',
                      '#CATEGORY#': 'category',
                      '#PRODUCT#': 'product'
                  }
              }   
          },  
        methods: {
            async dispatchSeo(to){
              if(this.$store){
                  this.$store.dispatch('router/getSeo', to)
              }
            },
            // get city &amp; area from store and suffix it to url
            // AND get language slug and prefix it ti url
            seoPath(slug){
                // if router object
                if(typeof slug === 'object') {
                  let route = this.$router.resolve(slug)
                  slug = route.href
                }         
                
                let slash = slug.endsWith('/')? '': '/';
                
                let url_location = [
                      this.$store.state.router.city.slug,
                      this.$store.state.router.area.slug
                ].filter((item) =&gt; {
                    return item !== null &amp;&amp; item !== ''
                });
                
                return this.localePath(slug + slash + url_location.join('/'))
            },
            // get string and replace all variables with data form store using variable's aliase array
            replaceVariables(string){
              const reg = new RegExp('(#CITY#|#CITY_PRED#|#CITY_REGION#|#CITY_REGION_PRED#|#NAME#|#MIN.PRICE#|#CATEGORY#|#SUBCATEGORY#|#PRODUCT#)', 'gi');
              return string.replaceAll(reg, (match) =&gt; {
                  
                  let modal = this.variableAliases[match]
                  
                  if(this.$store.state.router[modal] &amp;&amp; this.$store.state.router[modal].name)
                      return  this.$store.state.router[modal].name
                  else
                      return '';
      
              })
            }
        },
        computed: {
            seoH1(){
                if(this.$store)
                  if(this.$store.state.router.seo &amp;&amp; this.$store.state.router.seo.meta_h1)
                      return this.replaceVariables(this.$store.state.router.seo.meta_h1)
                  else
                      return ''
            },
            seoTitle(){
                if(this.$store)
                  if(this.$store.state.router.seo &amp;&amp; this.$store.state.router.seo.meta_title)
                      return this.replaceVariables(this.$store.state.router.seo.meta_title) 
                  else
                      return ''
            },
            seoDesc(){
                if(this.$store)
                  if(this.$store.state.router.seo &amp;&amp; this.$store.state.router.seo.meta_desc)
                      return this.replaceVariables(this.$store.state.router.seo.meta_desc) 
                  else
                      return ''
            },
            seoText(){
                if(this.$store)
                  if(this.$store.state.router.seo &amp;&amp; this.$store.state.router.seo.meta_text)
                      return this.replaceVariables(this.$store.state.router.seo.meta_text)
                  else
                      return '' 
            }
        }
    })
  }
  </code></pre>