Fixing local development and offline builds

This commit is contained in:
podar 2024-10-27 02:16:02 -05:00
parent 22865c010a
commit 9983ccfd18
2 changed files with 10 additions and 5 deletions

View File

@ -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();
@ -94,15 +95,19 @@ const startGame = async () => {
version: version
});
game.sound.pauseOnBlur = false;
if (manifest) {
game["manifest"] = manifest;
}
};
fetch("/manifest.json")
.then(res => res.json())
.then(jsonResponse => {
startGame();
game["manifest"] = jsonResponse.manifest;
}).catch(() => {
// Manifest not found (likely local build)
manifest = jsonResponse.manifest;
}).catch(err => {
// Manifest not found (likely local build or error path on live)
console.log(`Manifest not found. ${err}`);
}).finally(() => {
startGame();
});

View File

@ -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",