mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-11-25 20:42:40 +00:00
New preact based frontend UI for the TTT.
Added rollup compiling
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
const glob = require('./lib/glob');
|
||||
const { ROOT, readFile } = require('./resolve');
|
||||
const { ROOT, readFile, resolve } = require('./resolve');
|
||||
const actions = require('./actions');
|
||||
const File = require('./file');
|
||||
const Promise = require('bluebird');
|
||||
const { minify } = require('terser');
|
||||
const rollup = require('./rollup');
|
||||
|
||||
module.exports = exports = async function scripts (prod) {
|
||||
const globalFiles = await glob('js/_*.js', { cwd: ROOT, nodir: true });
|
||||
@@ -18,10 +19,12 @@ module.exports = exports = async function scripts (prod) {
|
||||
const globalScript = new ClientScript('js/global.js');
|
||||
await globalScript.concat(globalFiles, prod);
|
||||
|
||||
const files = await Promise.map(glob('js/*.js', { cwd: ROOT, nodir: true }), async (filepath) => {
|
||||
const files = await Promise.map(glob('js/*.{js,jsx}', { cwd: ROOT, nodir: true }), async (filepath) => {
|
||||
const f = new ClientScript(filepath);
|
||||
if (f.preprocessed) return false;
|
||||
if (f.globalScript) return false;
|
||||
|
||||
await f.load(prod);
|
||||
|
||||
return f;
|
||||
}).filter(Boolean);
|
||||
|
||||
@@ -35,12 +38,35 @@ module.exports = exports = async function scripts (prod) {
|
||||
|
||||
class ClientScript extends File {
|
||||
|
||||
_basename (file) {
|
||||
super._basename(file);
|
||||
|
||||
this.globalScript = false;
|
||||
if (file.name[0] === '_') {
|
||||
this.globalScript = true;
|
||||
file.name = file.name.slice(1);
|
||||
file.base = file.base.slice(1);
|
||||
}
|
||||
|
||||
this.rollup = false;
|
||||
if (file.name[0] === '$') {
|
||||
this.rollup = true;
|
||||
file.name = file.name.slice(1);
|
||||
file.base = file.base.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
_dir (dir) {
|
||||
dir = dir.split('/');
|
||||
return dir;
|
||||
}
|
||||
|
||||
async load (prod) {
|
||||
if (this.rollup) {
|
||||
this.content = await rollup(resolve(this.input), prod);
|
||||
return;
|
||||
}
|
||||
|
||||
let contents = (await readFile(this.input).catch(() => '')).toString('utf8');
|
||||
if (prod) {
|
||||
const { code, error } = minify(contents);
|
||||
|
||||
Reference in New Issue
Block a user