Jump to content
Search Community

Francesco Michelini

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Francesco Michelini

  1. Hi all,

     

    I just stumbled upon this exact "problem" with Nuxt 3.1.1, but I've been able to make it work only by omitting the `.client` part in the plugin file name.

     

    In my case, importing the SplitText and Draggable plugins made the entire application crash during development because at the very beginning the `window` object is still `undefined` (only on the first page load. instead, when navigating towards a page that used those plugins no errors were thrown).

     

    Maybe this will be helpful to others in the future ✌️

     

    For reference 👇

    // /plugins/gsap.js
    
    import { gsap } from 'gsap'
    import { ScrollTrigger } from 'gsap/ScrollTrigger'
    import { Draggable } from 'gsap/Draggable'
    import { InertiaPlugin } from 'gsap/InertiaPlugin'
    import { Observer } from 'gsap/Observer'
    
    export default defineNuxtPlugin(() => {
      gsap.registerPlugin(Observer, ScrollTrigger, InertiaPlugin)
    
      if (process.client) {
        gsap.registerPlugin(Draggable)
      }
    
      return {
        provide: {
          gsap,
          Observer,
          ScrollTrigger,
          Draggable
        }
      }
    })

     

    • Like 1
    • Thanks 1
×
×
  • Create New...