I would like to create mobile game with Phaser and Cordova.
From index.html
< script src=“js/phaser.min.js”>< /script>
< script src=“js/index.js” type=“module”></ script>
index.js attaching multiple js file.
From js/index.js
import MainScene from “./main-scene.js”;
import Player from “./player.js”;
import Enemy from “./enemy.js”;
const config = {
…
}
…
My game can run successfully on Brower.
but when I using cordova to build android apk and test on my phone.
It displays a blank page…
Is it possible to use Modules/Imports method to build the Cordova apk app???
Thank you very much
I’m using with webpack and building using cordova for android and ios, and so far so good.
You can give a try with webpack
Then after you just need configure cordova:

Oh, I found the solution
The problem is I forgot to set webpack.config.js
and type
module.exports = { entry: { app: './src/index.js') }...
and not need to type < script js/index.js” type=“module”> in index.html file
now, My game can run on my phone, thank you very much
and thank you for rafinha2k reply.
1 Like
Hi, Kheug35.
I’m stucked at the same point. I don’t know what am I doing wrong: I’ve configured and executed webpack to generate a bundle.js with all the js code. Then, if I remove the original js files, everything works fine on the browser. BUT, when I copy my bundle file into the imported AndroidStudio project and run it on an emulator, all I can see is a blank screen.
Could you please, help me?
Thanks