Skip to content

Commit

Permalink
Fixing local development and offline builds
Browse files Browse the repository at this point in the history
  • Loading branch information
podarsmarty committed Oct 27, 2024
1 parent dfb42e4 commit 17cd16f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "pokemon-rogue-battle",
"private": true,
"version": "1.1.2",
"version": "1.1.3",
"type": "module",
"scripts": {
"start": "vite",
"start:dev": "vite --mode development",
"start:dev": "git submodule update --init --recursive && vite --mode development",
"build": "vite build",
"build:beta": "vite build --mode beta",
"preview": "vite preview",
Expand Down
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative
document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems"));

let game;
let manifest;

const startGame = async () => {
await initI18n();
Expand Down Expand Up @@ -94,16 +95,18 @@ const startGame = async () => {
version: version
});
game.sound.pauseOnBlur = false;
game["manifest"] = manifest;
};

fetch("/manifest.json")
.then(res => res.json())
.then(jsonResponse => {
manifest = jsonResponse.manifest;
}).catch(err => {
// Manifest not found (likely local build or error path on live)
console.log(`Manifest not found. ${err}`);
}).finally(() => {
startGame();
game["manifest"] = jsonResponse.manifest;
}).catch(() => {
// Manifest not found (likely local build)
// startGame();
});

export default game;
2 changes: 1 addition & 1 deletion src/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export async function initI18n(): Promise<void> {
} else {
fileName = camelCaseToKebabCase(ns);
}
return `/locales/${lng}/${fileName}.json?v=${pkg.version}`;
return `./locales/${lng}/${fileName}.json?v=${pkg.version}`;
},
},
defaultNS: "menu",
Expand Down

0 comments on commit 17cd16f

Please sign in to comment.