Jump to content

How do I minify my JS game files?


Gamma
 Share

Recommended Posts

I am currently using the Phaser project template located on Github. I tried to search online for a way to minify my game files, yet I've ran into pages that talk about using 'GruntJS'. I am currently not familiar with the javascript task runner. Can anyone give me links to tutorials on how to minify phaser games? Or can anyone post a detailed description on how to do so? I would appreciate it greatly. 

Link to comment
Share on other sites

Just copy the whole folder into a new folder, use the site and minify the new version on the website. Its as simple as that.

Aslong as the js files are minified then the folders and other stuff are irrelevant.

The site is as simple as copy the file, press compress, copy the compressed js text and paste back to the original js and save it.

That's the minified version.

Copy the whole folder in together and it will minify the whole thing in one go.

Link to comment
Share on other sites

  • 6 months later...
  • 3 years later...

I realise this thread is super old, but I wanted to throw my two cents in, because a) I hate grunt, and b) the first time I tried a standard uglify call, it failed and broke everything.

For a while now I've used a free GUI tool called Koala (because I'm a sucker for a nice, simple GUI) for compressing CSS & JS in websites. It occurred to me to try it with my first Phaser game, but I wasn't holding out that much hope, because my game comprised 10 states, 18 prefabs, 2 plugins, and for the hell of it I threw in a couple of extra JS files I was using for the overall page. The first time I ran it, it failed (boo!), but then I selected the Harmony (ES6+) option in Koala, and it compiled everything successfully, and the game ran perfectly.

I've attached a screenshot of my Koala settings. I created a single `site.js` file, and you use a proprietary syntax in that to include all the relevant JS files; e.g.:

// @koala-append "mywebsite.js"
// @koala-append "plugins/Sound.js"
// @koala-append "states/BootState.js"
// @koala-append "states/GameState.js"
// etc. etc.

Then just select your `site.js` file, hit Compile, and BOOM! All of your JavaScript files are compiled into a single file, with all the comments & whitespace removed, all the variables renamed, and all the other uglifying features you come to expect (as Koala makes use of UglifyJS).

koala.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...