mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-08 09:24:48 +00:00
.
This commit is contained in:
parent
c4c10917ee
commit
696861c894
49
build_fast.ts
Normal file
49
build_fast.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import { $, build } from 'bun';
|
||||||
|
import { readdirSync, statSync, writeFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
function getFiles(baseDir: string, dir?: string, filesArr?: string[]) {
|
||||||
|
dir = dir ?? baseDir;
|
||||||
|
filesArr = filesArr ?? [];
|
||||||
|
const files = readdirSync(dir);
|
||||||
|
for (const file of files) {
|
||||||
|
const name = join(dir, file);
|
||||||
|
if (statSync(name).isDirectory()) {
|
||||||
|
getFiles(baseDir, name, filesArr);
|
||||||
|
} else {
|
||||||
|
filesArr.push(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filesArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(chalk.cyan('Removing old build artifacts...\n'));
|
||||||
|
await $`rm -rf ./public/resources/scripts/ ./public/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
|
||||||
|
|
||||||
|
console.log(chalk.cyan('Bundling TypeScript and modules...\n'));
|
||||||
|
const srcFilesArr = getFiles(join(import.meta.dir, 'src'));
|
||||||
|
await build({
|
||||||
|
entrypoints: srcFilesArr,
|
||||||
|
outdir: './public/',
|
||||||
|
target: 'browser',
|
||||||
|
root: './src/',
|
||||||
|
minify: {
|
||||||
|
syntax: true,
|
||||||
|
whitespace: true,
|
||||||
|
identifiers: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(chalk.cyan('Generating assets list...\n'));
|
||||||
|
const publicDir = join(import.meta.dir, 'public');
|
||||||
|
writeFileSync(
|
||||||
|
join(publicDir, 'assets.json'),
|
||||||
|
JSON.stringify(
|
||||||
|
getFiles(publicDir).map((asset) => {
|
||||||
|
return asset.replace(new RegExp(`^${publicDir}`), '').replace(/\/index\.html$/, '/');
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(chalk.green('Build complete!\n'));
|
@ -8,7 +8,8 @@
|
|||||||
"dev": "NODE_ENV=development DEBUG=app:* bun --hot run ./index.ts",
|
"dev": "NODE_ENV=development DEBUG=app:* bun --hot run ./index.ts",
|
||||||
"lint": "eslint ./src/",
|
"lint": "eslint ./src/",
|
||||||
"lint:fix": "eslint --fix ./src/",
|
"lint:fix": "eslint --fix ./src/",
|
||||||
"build": "bun run ./build.ts"
|
"build": "bun run ./build.ts",
|
||||||
|
"build:fast": "bun run ./build_fast.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user