Hi, I am having trouble building and deploying to a github pages site.
In an issue here (https://github.com/photonstorm/phaser/issues/5083) Rich hinted that I need to set the base url, and I assumed
this.load.setBaseUrl()
was how I should do it, but it doesn’t seem to affect the paths at all in the final build…
Unfortunately, the docs don’t explain what string to pass in here and if there something additional you need to do to get it working.
Hi,
I think the final build is handled by the builder, i use the phaser-template, with webpack already configured for phaser:
And never got build problems.
Edit: @JimLynchCodes
I downloaded your game on github, and configured it to work with the phaser3-project-template.
I have webgl problems with the background image, probably too big, but the game works.
I added a camera setBounds and body size for the player and enemies.
You can build with
npm run build
and everything works well. (dist folder is created in the webpack folder, my config isn’t finished)
Nice game!!
Thanks @BlunT76!
Did you try deploying it to gh-pages?
I don’t see where you are setting the baseUrl here. Are you setting the path prefix somewhere?
I didn’t set the baseUrl, no need with this template, or it is already defined somewhere.
I didn’t tried to deploy to gh-pages, just run a build and tested it locally with a php server
I don’t think you are understanding the issue. I WANT to deploy to github pages because then other people can play it, and gh-pages is free.
I forked your template and in dist
this is what the index.html looks like:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript" src="vendors.bundle.js"></script><script type="text/javascript" src="bundle.min.js"></script></body>
</html>
These are the same non-prefixed file paths that I’m getting when I build and so it won’t work when deploying unless I add the baseUrl…
Ok, i don’t use gh-pages, i use itch.io (free too) so i can’t test it sorry…
Ok, got it to work on gh-pages
https://blunt76.github.io/fishHelp/
Just modified the package.json with:
"scripts": {
"build": "webpack --config webpack/prod.js ",
"start": "webpack-dev-server --config webpack/base.js --open",
"deploy": "gh-pages -d dist"
},
Changed webpack/prod.js:
output: {
filename: "bundle.min.js",
path: path.resolve(__dirname, '../dist'),
},
then
npm run build
npm run deploy
i push all the modifications so you can clone and test my repo
Wow, that’s amazing!
Thanks! It is working when I deploy it too. I am still confused why this works my my other one doesn’t since they seem to be the same and running the build and you didn’t need to specify the base url anywhere.
Btw I would like to try itchio, but when I try to login with github I get an error:
We had some trouble connecting your account
- Invalid state, please try again
Geez, am I just super unlucky when it comes to computers?