Jump to content
Search Community

GULP Terser minification on dist/gsap.js breaks gsap.

Darcey test
Moderator Tag

Go to solution Solved by Darcey,

Recommended Posts

Hi,

 

I seem to have an issue when trying to use gulp to concat and minify gsap, error reads:

libs.js:4 Uncaught TypeError: Cannot set property window of #<Window> which has only a getter

 

image.png.604316c3091d6d2c5f5aff01421064b3.png

 

 

So I created a new folder and setup the following:

1. CMD: npm init -y

2. CMD: npm i -S gsap gulp gulp-contact gulp-terser gulp-rename
3. Create gulpfile.js
 

let jsFiles = [
   "./node_modules/gsap/dist/gsap.js",
];
 
let buildLibsProd = function (done) {
    gulp.src(jsFiles)
        .pipe(concat('libs.min.js'))
        .pipe(terser())
        .on("error"function (e) {
            console.log(e.toString());
            this.emit("end");
        })
        .pipe(gulp.dest('./'));
    done();
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gulp.task("buildJs"gulp.parallel(
    buildLibsProd
));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

4. Create index.html

5. Add script tag link in head to libs.min.js (will give you console log error).
6. Comment out script tag

7. Add another script tag link in head to ./node_modules/gsap/dist/gsap.min.js (no console errors)

 

Any ideas?

 

 

Works fine in my Webpack projects...

 

Link to comment
Share on other sites

Yeah, that definitely sounds like a Gulp question, not a GSAP question. Sorry - we're pretty focused around here on GSAP-specific questions. I wish I had more knowledge of the inner workings of Gulp but perhaps a Gulp-focused forum could help? From that error, it sounds like "this" in the context that's running is an object that has a read-only window property. Not exactly sure how you can alter that in Gulp. 

  • Like 1
Link to comment
Share on other sites

  • Solution

Found the issue... Was me just being blind and going to fast with auto complete!!

 

I started to create a public git repo for the github forums, built all from scratch and found it worked... Done a little visual compare on files and found auto complete inserted

type="module"

Into the script tag...

 

Can't believe I missed that... It's always the smallest of things that get you...

  • Like 2
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...