I have a Green Sock animation that is working fine in development, but breaks in yarn run preview and production: ScrollTrigger-4a410f45.js:9 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'name'). The result is that the the point I'm trying to animate along the path is not positioned on the path and does not move.
import { gsap } from 'gsap';
import { MotionPathPlugin } from 'gsap/dist/MotionPathPlugin.js';
let reference, path, ico;
onMount(async () => {
gsap.registerPlugin(ScrollTrigger, MotionPathPlugin);
gsap.timeline({
defaults: { duration: 1 },
scrollTrigger: {
trigger: reference,
}
})
.to(ico, { duration: 0.01, autoAlpha: 1 })
.to(ico, {motionPath: {path: path, align: path, alignOrigin: [0.5, 0.5]}}, 0);
});
I have no issues with this locally, the error only shows in the production build. I'm not sure if this is something with my Green Sock code or my Svelte config. Any tips or a solution would be greatly appreciated.