mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-02-07 18:16:17 +00:00
Fix global scripts getting saved
This commit is contained in:
parent
f6887d4b39
commit
e14069514a
@ -21,7 +21,7 @@ module.exports = exports = async function scripts (prod) {
|
|||||||
|
|
||||||
const files = await Promise.map(glob('js/*.{js,jsx}', { 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);
|
const f = new ClientScript(filepath);
|
||||||
if (f.globalScript) return false;
|
if (f.preprocessed) return false;
|
||||||
|
|
||||||
await f.load(prod);
|
await f.load(prod);
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ module.exports = exports = async function scripts (prod) {
|
|||||||
const tasks = files.map((f) => f.tasks()).flat();
|
const tasks = files.map((f) => f.tasks()).flat();
|
||||||
|
|
||||||
tasks.push(...globalScript.tasks());
|
tasks.push(...globalScript.tasks());
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,13 +40,6 @@ class ClientScript extends File {
|
|||||||
_basename (file) {
|
_basename (file) {
|
||||||
super._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;
|
this.rollup = false;
|
||||||
if (file.name[0] === '$') {
|
if (file.name[0] === '$') {
|
||||||
this.rollup = true;
|
this.rollup = true;
|
||||||
@ -69,7 +61,7 @@ class ClientScript extends File {
|
|||||||
|
|
||||||
let contents = (await readFile(this.input).catch(() => '')).toString('utf8');
|
let contents = (await readFile(this.input).catch(() => '')).toString('utf8');
|
||||||
if (prod) {
|
if (prod) {
|
||||||
const { code, error } = minify(contents);
|
const { code, error } = minify(contents, { output: { comments: false } });
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
contents = code;
|
contents = code;
|
||||||
}
|
}
|
||||||
@ -80,7 +72,7 @@ class ClientScript extends File {
|
|||||||
let contents = await Promise.map(files, readFile);
|
let contents = await Promise.map(files, readFile);
|
||||||
contents = contents.join('\n\n');
|
contents = contents.join('\n\n');
|
||||||
if (prod) {
|
if (prod) {
|
||||||
const { code, error } = minify(contents);
|
const { code, error } = minify(contents, { output: { comments: false } });
|
||||||
if (error) throw new Error(error);
|
if (error) throw new Error(error);
|
||||||
contents = code;
|
contents = code;
|
||||||
}
|
}
|
||||||
@ -88,7 +80,7 @@ class ClientScript extends File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks () {
|
tasks () {
|
||||||
|
if (this.preprocessed) return [];
|
||||||
return [ {
|
return [ {
|
||||||
input: this.input,
|
input: this.input,
|
||||||
output: this.out,
|
output: this.out,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user