I have a lot of classes extending Phaser.Sprite. Building each one by hand via some if statement when loading a tilemap is dumb. Thankfully, webpack is here to rescue me.
The full code of entityFactory.js is below.
Say you've got a directory full of sprites, each one a subclass of Phaser.Sprite: