Using greensock with browserify

2019-07-04 05:23发布

I'm not able to get TweeLite to work with browserify. I'm an extreme noob when it comes to CommonJS.

I've installed gasp v1.13.2 using Bower and include it like this:

var TweenLite = require("../../bower_components/gsap/src/minified/TweenLite.min.js");

I don't get any errors when using it, but my animations don't work. According to gsap docs this version should work without a shim. What am I doing wrong? Can anyone provide a working example?

https://greensock.com/gsap-1-13-1

I've just started on a project so I dont have any interesting code to show. I'm using the gulp-starter boilerplate.

2条回答
太酷不给撩
2楼-- · 2019-07-04 05:44

GSAP is also available through NPM so you should be able to install it via:

npm install gsap --save

and use it the same way other libraries are referenced in the gulp-starter project eg in view.coffee:

_          = require 'underscore'
Backbone   = require 'backbone'
Backbone.$ = require 'jquery'
plugin     = require 'plugin'
//this line below makes TweenLite available in the browser in my quick tests.
gsap       = require 'gsap'
查看更多
放我归山
3楼-- · 2019-07-04 05:52

Try using the uncompressed GSAP libraries. I'm successfully using them through browserify and installed with bower. Like this:

var TweenLite = require('../bower_components/gsap/src/uncompressed/TweenLite.js');
var TimelineLite = require('../bower_components/gsap/src/uncompressed/TimelineLite.js');
var CSSPlugin = require('../bower_components/gsap/src/uncompressed/plugins/CSSPlugin.js');

However, if I switch to the compressed builds browserify no longer finds the modules.

It appear like the compression methods used to generate the minified builds somehow broke the module exports.

查看更多
登录 后发表回答