Jump to content
Search Community

Netlify build fails with ScrollToPlugin

ViVO Digital test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi,

 

We're encountering build errors after adding ScrollToPlugin to a project deployed on Netlify:

Could not load edge function at '/opt/build/repo/.netlify/edge-functions/handler/index.js'
ReferenceError: document is not defined

ScrollToPlugin is imported as follows:

import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/dist/ScrollTrigger';
import { ScrollToPlugin } from 'gsap/dist/ScrollToPlugin';

gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);

ScrollToPlugin works as expected during local development. Furthermore, ScrollTrigger and SplitText are used elsewhere in the project and build without issue. I'm hoping somebody's able to point us in the right direction.

 

Thanks in advance. :)

Link to comment
Share on other sites

On 11/22/2022 at 3:32 PM, GreenSock said:

My guess is that "document" is not defined yet when you are registering the plugin (like SSR?). Can you move that gsap.registerPlugin() call to a place in your code where you know for sure that the document exists? 

 

Thanks for stepping in to help out once again, Jack (you helped me before we created our org account)! We'll look into this asap and post the outcome here.

 

Chris

  • Like 1
Link to comment
Share on other sites

Thanks Jack, the component we are using is in a client component but at the root level it gets called in from a server component. Shopify Hydrogen to be specific, it has a `isBrowser` flag similiar to the `process.client` example shown in the GSAP docs. I have wrapped the `registerPlugin` inside `isBrowser` but still no dice. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...