Jump to content
Search Community

ScrollToPlugin fails in webpack production build

Robert Wildling test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

God evening, all!

 

I have a webpack 4 setup, where the ScrollPlugin loads in development mode, but not in production mode.

 

The reason is that the plugin is not loaded in production mode, but is IS loaded in development mode.

My setup looks like this

 

```js
import {  TweenMax } from 'gsap'
import ScrollToPlugin from '../../node_modules/gsap/src/minified/plugins/ScrollToPlugin.min.js';
import 'animation.gsap'
import 'debug.addIndicators'
```

 

(This solution is also from somewhere in the forums here.)

Unfortunately, webpack's tree shaking remove the ScrollToPlugin, probably also, because it is never defined anywhere, which makes webpack (and also VSCode) think that it is never used – that at least is my assumption! Please feel free to correct me on that!

 

However, if I use `require([path/to/scrolltoplugin])` things work fine in production mode, too. *Magic*

This seems inconcise... irregular... wrong... incomplete... I am surely doing something wrong, misunderstanding a concept here... Could you set my head straight, please?

 

Do you guys have a different solution to that problem?

 

Or: @GreenSock Do you think this needs an implementation change on the ScrollToPlugin side?

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