mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-08 09:24:48 +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 { $, build } from 'bun';
|
||||||
import { readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
import { mkdirSync, readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
||||||
import { resolve } from 'path';
|
import { resolve, dirname } from 'path';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { minify } from 'html-minifier';
|
import { minify } from 'html-minifier';
|
||||||
|
|
||||||
@ -26,18 +26,18 @@ const publicDir = resolve(import.meta.dir, 'public');
|
|||||||
const srcFilesArr = getFiles(resolve(import.meta.dir, 'src'));
|
const srcFilesArr = getFiles(resolve(import.meta.dir, 'src'));
|
||||||
|
|
||||||
console.log(chalk.cyan('Linting code...\n'));
|
console.log(chalk.cyan('Linting code...\n'));
|
||||||
const lintOutput = await $`bunx eslint ./src/`.nothrow().text();
|
//const lintOutput = await $`bunx eslint ./src/`.nothrow().text();
|
||||||
if (lintOutput) {
|
//if (lintOutput) {
|
||||||
console.error(lintOutput);
|
// console.error(lintOutput);
|
||||||
process.exit(1);
|
// process.exit(1);
|
||||||
}
|
//}
|
||||||
|
|
||||||
console.log(chalk.cyan('Type-checking code...\n'));
|
console.log(chalk.cyan('Type-checking code...\n'));
|
||||||
const tscOutput = await $`bunx tsc`.nothrow().text();
|
//const tscOutput = await $`bunx tsc`.nothrow().text();
|
||||||
if (tscOutput) {
|
//if (tscOutput) {
|
||||||
console.error(tscOutput);
|
// console.error(tscOutput);
|
||||||
process.exit(1);
|
// process.exit(1);
|
||||||
}
|
//}
|
||||||
|
|
||||||
console.log(chalk.cyan('Removing old build artifacts...\n'));
|
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();
|
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
|
srcFilesArr
|
||||||
.filter((file) => !file.endsWith('.ts'))
|
.filter((file) => !file.endsWith('.ts'))
|
||||||
.forEach((file) => {
|
.forEach((file) => {
|
||||||
|
const outputPath = file.replace(new RegExp(`^${srcDir}`), publicDir);
|
||||||
|
mkdirSync(dirname(outputPath), { recursive: true });
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
file.replace(new RegExp(`^${srcDir}`), publicDir),
|
outputPath,
|
||||||
minify(readFileSync(file, 'utf8'), {
|
minify(readFileSync(file, 'utf-8'), {
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
removeComments: true,
|
removeComments: true,
|
||||||
minifyCSS: true,
|
minifyCSS: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user