#Combining and compressing JS, without wrapping it in bundle logic

12 messages · Page 1 of 1 (latest)

spring cypress
#

Hi there! I'm currently migrating an old site from a now-broken-and-unsupported CMS to Astro. It's going great so far, but I'm now trying to migrate the JS, and I've hit an issue.

The site is currently still using a lot of "old-style" JS - like a global jQuery, Backbone, even modernizr.js, etc. And for now, I don't really have the time to change that, so I need to make that work. So, what's the best way to have Astro combine multiple JS files into one by simply appending it, and minifying the files, but not wrapping it in any separation/bundling logic?

If I just add script tags, then obviously the application complains, because blog.js for example can't find the global Backbone object. I also can't also create a new js file and use import to import the old JS - modernizr for example relies on this.document be defined... :/

I could probably try to find all the dependencies in their right, old, versions from NPM to have them bundler-compatible, but urgh

queen vector
spring cypress
#

oh yeah, that works! buuuut ideally, I'd have Astro combine all the files together and compress them, but not bundle them :D

#

I could just do that manually obviously, I don't expect there to be any changes to that (I'm migrating it for "archival", mainly). But I wonder if there's a nicer way of doing that

queen vector
spring cypress
#

yeah. one giant file, then strip out newlines etc. like the really old school sites did

#

although I feel like this is the kind of story where I'd end up modifying rollup configs via vite config via astro. :/

queen vector
queen vector
spring cypress
#

I think it's easier to... just not do that, and either completely ignore that (one could argue that transport encryption and http2/http3 batching probably makes that irrelevant anyway), or write a little script that does that once in this case

#

but I'll see if I find something easy :)

#

appreciate the help, though!