
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
phaser-webpack-loader
Advanced tools
Instead of manually calling scene.load.image, scene.load.audio, etc for every asset in your game (and then dealing with caching issues), phaser-webpack-loader lets you define all assets in a simple manifest file and handles the rest for you.
NOTE: This plugin now only supports Phaser 3 and later. If you need support for Phaser 2, use v1.1.0.
Install the plugin through NPM (or Yarn):
npm install phaser-webpack-loader --save
Then create your manifest file and add the plugin as outlined below.
const AssetManifest = {
images: [
'image001.png',
'image002.jpg',
'...',
],
sprites: [
'sprite001.png',
'sprite002.png',
'...',
],
audio: [
'audio001.webm',
'audio002.mp3',
'...',
],
bitmapFonts: [
'font001.png',
'font002.png',
'...',
],
fonts: {
google: {
families: [
'Open Sans:300,700',
],
},
},
};
export default AssetManifest;
In your preload state, add the plugin. It uses promises, which makes it flexible to move to the next step when ready.
import WebpackLoader from 'phaser-webpack-loader';
import AssetManifest from '../AssetManifest';
export default class Preload extends Phaser.Scene {
preload() {
this.load.scenePlugin('WebpackLoader', WebpackLoader, 'loader', 'loader');
}
create() {
this.loader.start(AssetManifest);
this.loader.load().then(() => {
// Done loading!
});
}
}
If you want to load high DPI assets, you can pass an optional postfix string:
this.loader.start(AssetManifest, '@2x');
If you want to know when each file is loaded, use the optional callback:
this.loader.systems.events.on('load', (file) => {
console.log('File loaded!', file);
});
The font loader uses Web Font Loader, which supports loading web fonts from all major providers. Simply provide their standard configuration object in your manifest.
All sprite/atlas files are loaded as JSON hashes (which can be output using TexturePacker, Shoebox and others). All you have to specify in the manifest is the image filename, but you'll also need to include the JSON hash file alongside it, which will automatically get loaded and used.
Specify the base directory in your Webpack config:
resolve: {
alias: {
assets: path.join(__dirname, '../src/assets'),
},
},
Then, place your assets in the following sub-directories:
assets/
├── images/
├── sprites/
├── audio/
└── fonts/
This plugin is not pre-compiled to ES5, so you'll want to make sure your Webpack config rules are setup to not exclude it:
module: {
rules: [
{
test: /\.js$/,
loader: '...',
exclude: /node_modules\/(?!phaser-webpack-loader)/,
},
],
...
},
Copyright (c) 2018 James Simpson and GoldFire Studios, Inc.
Released under the MIT License.
FAQs
Asset loader for Phaser + Webpack.
We found that phaser-webpack-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.