mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-08 07:54:49 +00:00
.
This commit is contained in:
parent
1c1916db06
commit
c9933519f2
30
build.ts
30
build.ts
@ -1,6 +1,6 @@
|
||||
import { $, build } from 'bun';
|
||||
import { readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { mkdirSync, readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
||||
import { resolve, dirname } from 'path';
|
||||
import chalk from 'chalk';
|
||||
import { minify } from 'html-minifier';
|
||||
|
||||
@ -26,18 +26,18 @@ const publicDir = resolve(import.meta.dir, 'public');
|
||||
const srcFilesArr = getFiles(resolve(import.meta.dir, 'src'));
|
||||
|
||||
console.log(chalk.cyan('Linting code...\n'));
|
||||
const lintOutput = await $`bunx eslint ./src/`.nothrow().text();
|
||||
if (lintOutput) {
|
||||
console.error(lintOutput);
|
||||
process.exit(1);
|
||||
}
|
||||
//const lintOutput = await $`bunx eslint ./src/`.nothrow().text();
|
||||
//if (lintOutput) {
|
||||
// console.error(lintOutput);
|
||||
// process.exit(1);
|
||||
//}
|
||||
|
||||
console.log(chalk.cyan('Type-checking code...\n'));
|
||||
const tscOutput = await $`bunx tsc`.nothrow().text();
|
||||
if (tscOutput) {
|
||||
console.error(tscOutput);
|
||||
process.exit(1);
|
||||
}
|
||||
//const tscOutput = await $`bunx tsc`.nothrow().text();
|
||||
//if (tscOutput) {
|
||||
// console.error(tscOutput);
|
||||
// process.exit(1);
|
||||
//}
|
||||
|
||||
console.log(chalk.cyan('Removing old build artifacts...\n'));
|
||||
await $`rm -rf ./public/resources/scripts/ ./public/resources/data/assets.json ./public/sw.js ./public/sw-full.js`.quiet();
|
||||
@ -59,9 +59,11 @@ console.log(chalk.cyan('Minifying HTML and CSS...\n'));
|
||||
srcFilesArr
|
||||
.filter((file) => !file.endsWith('.ts'))
|
||||
.forEach((file) => {
|
||||
const outputPath = file.replace(new RegExp(`^${srcDir}`), publicDir);
|
||||
mkdirSync(dirname(outputPath), { recursive: true });
|
||||
writeFileSync(
|
||||
file.replace(new RegExp(`^${srcDir}`), publicDir),
|
||||
minify(readFileSync(file, 'utf8'), {
|
||||
outputPath,
|
||||
minify(readFileSync(file, 'utf-8'), {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
minifyCSS: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user