Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Daniel Hult

Laravel Mix treeshakes ScrollTrigger

Recommended Posts

Hi guys,

I actually just figured out the solution after some hours trying to figure out what was causing the problem. Wanted to write a topic here in case anybody else has this issue, or if it's relevant to the Greensock team:

When you run Laravel Mix (a webpack wrapper) in production mode it treeshakes (I think) plugins from gsap, even if you registered the plugin:

import { gsap } from 'gsap';
import Scrolltrigger from 'gsap/ScrollTrigger';

gsap.registerPlugin(Scrolltrigger);


//animation code


It works fine in development mode.


The solution is to add this setting in the "terserOptions" in the webpack.mix.js file:

 

	.options({
		terser: {
			terserOptions: {
				keep_fnames: true,
			},
		},
	})


Hope this helps somebody some day 😊


 

  • Thanks 2
Link to comment
Share on other sites

That's super weird/annoying that it'd treeshake code that's actually referenced in your own code! 🙄 Sure seems like a bug in their part.

 

But thanks so much for sharing the workaround. People search these forums all the time, so I have no doubt that this will help someone in the future. 🙌

Link to comment
Share on other sites

Thanks! That just means terser was being a little too aggressive with renaming stuff.

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.
×