To test it I run: npx webpack, which results in a successful build. But when I get to the index.html in the browser, I get the following error:
ReferenceError: WEBGL_RENDERER is not defined [Learn More] [index.js] [...]
I import them in the game config like this:
import Phaser from "phaser";
// THE BELOW LINE BREAKS THE GAME WHEN USED
import UIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin.js';
import Main from "./scenes/main.js";
let config = {
type: Phaser.AUTO,
width: 800,
heigth: 600,
physics: {
default: "arcade",
arcade: {
gravity: {y: 0},
debug: true
}
},
plugins: {
scene: [{
key: 'rexUI',
plugin: UIPlugin,
mapping: 'rexUI'
}]
},
scene: [Main]
};
let game = new Phaser.Game(config);
If I remove the import UIPlugin from 'phaser3-rex-plugins/... and its references in the config, it works OK.
What am I doing wrong? Any idea on how to do to be able to use the UIPlugin?
Edit: I saw this post, but I don’t know how to apply the suggested solution to my project.
Sorry for the late response, it has been a while since I posted the question and received your answer, but now I had time to write here. I finally opted to adding the variables at index.html as a workaround:
<script>
// This is necessary to work. DON'T REMOVE
let WEBGL_RENDERER = true;
let CANVAS_RENDERER = true;
</script>
<!-- Below is where Phaser.Game() is called -->
<script src="index.js"></script>