separated web and api, build improvements

wip:
- separate web and api servers.
- script for building static pages.
- building improvements.
- async localisation preloading.
This commit is contained in:
wukko
2023-05-19 16:13:38 +06:00
parent fa4e418e36
commit 4d369170ff
13 changed files with 315 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
import * as esbuild from "esbuild";
import * as fs from "fs";
import { languageList } from "../localization/manager.js";
import { loadLoc, languageList } from "../localization/manager.js";
import page from "./pageRender/page.js";
function cleanHTML(html) {
@@ -10,6 +11,9 @@ function cleanHTML(html) {
}
export async function buildFront(commitHash, branch) {
try {
// preload localization files
await loadLoc();
// build html
if (!fs.existsSync('./build/')){
fs.mkdirSync('./build/');
@@ -17,6 +21,10 @@ export async function buildFront(commitHash, branch) {
fs.mkdirSync('./build/pc/');
fs.mkdirSync('./build/mob/');
}
// get rid of old build path
if (fs.existsSync('./min')) {
fs.rmSync('./min', { recursive: true, force: true });
}
for (let i in languageList) {
i = languageList[i];
let params = {
@@ -36,7 +44,7 @@ export async function buildFront(commitHash, branch) {
// build js & css
await esbuild.build({
entryPoints: ['src/front/cobalt.js', 'src/front/cobalt.css'],
outdir: 'min/',
outdir: 'build/min/',
minify: true,
loader: { '.js': 'js', '.css': 'css', },
charset: 'utf8'