mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: esbuild page loader
This commit is contained in:
1 parent
4ce8439e99
commit
a8aa163302
2 files changed
+15
-5
No files matched your search
@@ -1,21 +1,31 @@
|
||||
/* eslint-disable no-return-await */
|
||||
/* eslint-disable camelcase */
|
||||
import crypto from 'crypto';
|
||||
import { readFileSync } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { ObjectID } from 'mongodb';
|
||||
import * as bus from 'hydrooj/src/service/bus';
|
||||
import { Route, Handler } from 'hydrooj/src/service/server';
|
||||
import { PERM, PRIV } from 'hydrooj/src/model/builtin';
|
||||
import esbuild from 'esbuild';
|
||||
import markdown from './backendlib/markdown';
|
||||
|
||||
const {
|
||||
system, user, setting, problem, contest,
|
||||
} = global.Hydro.model;
|
||||
|
||||
const pages = Object.keys(global.Hydro.ui.manifest)
|
||||
.filter((file) => file.endsWith('.page.js'))
|
||||
.map((i) => readFileSync(join(global.Hydro.ui.manifest[i], i), 'utf-8'));
|
||||
const pageFiles = Object.keys(global.Hydro.ui.manifest)
|
||||
.filter((file) => file.endsWith('.page.js') || file.endsWith('.page.ts'));
|
||||
const build = esbuild.buildSync({
|
||||
format: 'iife',
|
||||
entryPoints: pageFiles.map((i) => join(global.Hydro.ui.manifest[i], i)),
|
||||
bundle: true,
|
||||
splitting: false,
|
||||
write: false,
|
||||
minify: !process.env.DEV,
|
||||
});
|
||||
if (build.errors.length) console.error(build.errors);
|
||||
if (build.warnings.length) console.warn(build.warnings);
|
||||
const pages = build.outputFiles.map((i) => i.text);
|
||||
|
||||
let constant = '';
|
||||
let hash = '';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.34.20",
|
||||
"version": "4.34.21",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user