Fixing local development and offline builds
This commit is contained in:
parent
22865c010a
commit
9983ccfd18
13
src/main.ts
13
src/main.ts
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue