Phaser 3 custom build

I need custom phaser 3 builds time to time and I am generating them as explained in Phaser 3 world issue 127 (https://madmimi.com/p/ffcfbc). But even though I didn’t add Sound class to the custom build, the generated build still has sound stuff in it. Here is the code I use to generate custom build:

require(‘polyfills’);

var CONST = require(‘const’);
var Extend = require(‘utils/object/Extend’);

var Phaser = {
Cameras: {
Scene2D: require(‘cameras/2d’)
},
Events: require(‘events/EventEmitter’),
Game: require(‘boot/Game’),

Renderer: require('renderer'),
Textures: require('textures'),
Scene: require('scene'),

Geom: require('geom'),
GameObjects: require('gameobjects'),
Input: require('input'),
Tweens:require('tweens'),
Loader:{
   LoaderPlugin:require('loader/LoaderPlugin')
},
Time:require('time'),
Display:require('display'),

};

// Merge in the consts
Phaser = Extend(false, Phaser, CONST);

// Export it

module.exports = Phaser;

global.Phaser = Phaser;

Is there anyway I can remove sounds from Phaser altogether?

I think the sound classes are always included in the build (via SoundManagerCreator). You could add a feature request for that.

2 Likes

Thanks

You can try replacing the entire SoundManagerCreator.js (removing all imports):

/**
 * @function Phaser.Sound.SoundManagerCreator
 *
 * @param {Phaser.Game} game - Reference to the current game instance.
 *
 * @return {null} null
 */
var SoundManagerCreator = {

    create: function (game)
    {
        return null;
    }

};

module.exports = SoundManagerCreator;

I managed to remove the sounds from custom build. Because the boot/Game is adding SoundManager, all sound related classes are also included to the custom build. So I removed the SoundManager codes from the Game.js and all sounds are gone as far as I can see.

Game.js is located under \node_modules\phaser\src\boot in case anyone needs.