Jump to content
Search Community

Remove GSAP import and use CDN when using vite build

ChazUK test
Moderator Tag

Recommended Posts

This might be a bit outside the expertise of the GSAP team, but I thought I'd ask here just in case anyone has ideas.

 

I've built a workspace that uses Vite, Rollup and Typescript to create banners. Each banner has it's own project root, but can include files and assets from anywhere in the project making it easier to share files among banner projects. For instance I may need to create 20 versions using the same image and the same animation. Vite and Rollup lends itself really well to this as the preview server allows you to navigate to any folder with an index.html file and that will then load and compile all the lovely type safe JavaScript for development.

 

And then when it comes to building, its very easy to create a script that iterates over a number of banners, sets the project root and build directory for each and outputs them with just the assets, css and js that is needed.

 

Now my issue comes when compiling, obviously I need the banners to be as small as possible when finished, but my .js file has the full gsap minified code, which I want to add as a CDN link in the HTML. Is there a way to remove the import in Typescript whilst also keeping everything strongly typed?

Link to comment
Share on other sites

Hi,

 

I'm afraid I can't help you with this. Honestly I've never been n such position. My guess is that you could tell Vite to ignore certain packages in your build and still compile that, but type checking will be a pain point for sure. Maybe create some kind of custom configuration in your build system that first does the type checking and then runs a completely different command that creates the bundle ignoring GSAP.

 

As you mention this sounds more like a question for the folks at Vite rather than these forums.

 

Hopefully other users can chime in and help.

 

Happy Tweening!

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