Add mobile debug tools, fix building
This commit is contained in:
parent
8a9b437ae7
commit
e2ec4babb9
|
|
@ -35,7 +35,7 @@ export async function buildHTML(game: string, production = false, portable = fal
|
|||
console.log(bundle.outputs);
|
||||
return;
|
||||
}
|
||||
const iconFile = Bun.file(path.resolve(import.meta.dir, '..', 'games', game, 'assets', 'favicon.ico'));
|
||||
const iconFile = Bun.file(path.resolve(import.meta.dir, '..', 'src', 'games', game, 'assets', 'favicon.ico'));
|
||||
let icon = '';
|
||||
if (await iconFile.exists()) {
|
||||
icon = `<link rel="icon" href="data:;base64,${Buffer.from(await iconFile.arrayBuffer()).toString('base64')}" />`;
|
||||
|
|
@ -52,6 +52,7 @@ export async function buildHTML(game: string, production = false, portable = fal
|
|||
}
|
||||
|
||||
script = script.replaceAll('await Promise.resolve().then(() =>', '(');
|
||||
let scriptPrefix = '';
|
||||
if (production) {
|
||||
const minifyResult = UglifyJS.minify(script, {
|
||||
module: true,
|
||||
|
|
@ -61,10 +62,13 @@ export async function buildHTML(game: string, production = false, portable = fal
|
|||
} else {
|
||||
script = minifyResult.code;
|
||||
}
|
||||
} else {
|
||||
const eruda = await Bun.file(path.resolve(import.meta.dir, '..', 'node_modules', 'eruda', 'eruda.js')).text();
|
||||
scriptPrefix = `<script>${eruda};\neruda.init();</script>`;
|
||||
}
|
||||
|
||||
const resultHTML = html
|
||||
.replace('$SCRIPT$', `<script type="module">${script}</script>`)
|
||||
.replace('$SCRIPT$', () => `${scriptPrefix}<script type="module">${script}</script>`)
|
||||
.replace('$TITLE$', game[0].toUpperCase() + game.slice(1).toLowerCase())
|
||||
.replace('$ICON$', icon);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
"@types/inquirer": "9.0.7",
|
||||
"assemblyscript": "0.27.29",
|
||||
"bun-lightningcss": "0.2.0",
|
||||
"eruda": "3.2.3",
|
||||
"html-minifier": "4.0.0",
|
||||
"typescript": "5.5.2",
|
||||
"uglify-js": "3"
|
||||
|
|
|
|||
Loading…
Reference in New Issue