GoldFire Posted August 9, 2018 Share Posted August 9, 2018 We've been using Phaser-CE and doing custom builds to exclude components that we don't use (such as physics engines that we don't use, etc). I've been looking over the docs and don't see a way to do that in Phaser 3. Am I missing something or is that indeed the case? Link to comment Share on other sites More sharing options...
rich Posted August 9, 2018 Share Posted August 9, 2018 You can do incredibly granular builds of Phaser 3! Literally chop out anything you don't use, right down to single Actions or File Type Loaders. I'll write a proper tutorial on it for a Dev Log soon, but for now the key to it is using webpack to make a custom build by changing the contents of the entry point. Webpack uses src/phaser.js as the entry point for the 'full' build, and src/phaser-core.js for the 'core' build. If you look at these files you'll see they are basically a list of all the things to be included in a build, that is exposed under the Phaser namespace. If you look at the core file you'll see the GameObjects object breaks down into sections and that TileSprite and the Bitmap Text objects aren't in there for example. You can also see it's got far less Loader File Types too. Basically, anything in this file is bundled in. If you just link to a folder it'll take the index.js file from that folder and include everything in it: Actions: require('./actions') Here, every single Action will be included. But you could change it to this: Actions: { GridAlign: require('./actions/GridAlign'), RandomLine: require('./actions/RandomLine'), Shuffle: require('./actions/Shuffle') } Now, only the 3 Actions listed will be included. You don't have to worry about dependencies. For example, the Shuffle action requires the ArrayShuffle function from the utils/array folder, but it will be pulled in automatically because of the way webpack works. So think about the phaser.js file as being what you want Phaser to expose in its namespace. You could literally have nothing other than the 'Game' entry and that in itself will pull in everything it needs for a core, base Phaser to work. There won't be any Game Objects of course and no File Types for the Loader but it would still work. Perhaps if you were rendering a whole game using just the Graphics object then you could skip adding the Loader entirely! That's the basic gist of it anyway. Clone the repo, create your own phaser.js entry point, put in it whatever you use and let webpack worry about the rest. Tommy_, bobnobilo, jorbascrumps and 1 other 3 1 Link to comment Share on other sites More sharing options...
rich Posted September 4, 2018 Share Posted September 4, 2018 For anyone else coming to this, there is now a proper tutorial on how to do this. You can find it here. thosakwe, MeMyMo, B3L7 and 2 others 5 Link to comment Share on other sites More sharing options...
Recommended Posts