mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-24 01:29:36 +01:00
♻️ Update build script to support minification levels
Full minification by default
This commit is contained in:
parent
46869736d5
commit
19fd857dac
70
bs/build.js
70
bs/build.js
@ -2,39 +2,43 @@
|
||||
const files= [ "index.js", "index-with-signals.js" ];
|
||||
const filesOut= (file, mark= "esm")=> "dist/"+file.replace("index", mark);
|
||||
|
||||
for(const file of files){
|
||||
const out= filesOut(file);
|
||||
s.run([
|
||||
"npx esbuild '::file::'",
|
||||
"--platform=neutral",
|
||||
"--bundle",
|
||||
//"--minify",
|
||||
"--minify-syntax --minify-identifiers",
|
||||
"--legal-comments=inline",
|
||||
"--packages=external",
|
||||
"--outfile='::out::'"
|
||||
].join(" "), { file, out });
|
||||
pipe(
|
||||
f=> f.replace(/^ +/gm, m=> "\t".repeat(m.length/2)),
|
||||
f=> s.echo(f).to(out)
|
||||
)(s.cat(out));
|
||||
toDDE(out, filesOut(file, "dde"));
|
||||
}
|
||||
$.exit(0);
|
||||
$.api("", true)
|
||||
.option("--minify", "Level of minification [ full (default), partial ]")
|
||||
.action(function main({ minify= "full" }){
|
||||
for(const file of files){
|
||||
const out= filesOut(file);
|
||||
s.run([
|
||||
"npx esbuild '::file::'",
|
||||
"--platform=neutral",
|
||||
"--bundle",
|
||||
minify==="full" ? "--minify" : "--minify-syntax --minify-identifiers",
|
||||
"--legal-comments=inline",
|
||||
"--packages=external",
|
||||
"--outfile='::out::'"
|
||||
].join(" "), { file, out });
|
||||
pipe(
|
||||
f=> f.replace(/^ +/gm, m=> "\t".repeat(m.length/2)),
|
||||
f=> s.echo(f).to(out)
|
||||
)(s.cat(out));
|
||||
toDDE(out, filesOut(file, "dde"));
|
||||
}
|
||||
$.exit(0);
|
||||
|
||||
function toDDE(file, out){
|
||||
const name= "dde";
|
||||
echo(`\n ${out} (${file} → globalThis.${name})\n`);
|
||||
function toDDE(file, out){
|
||||
const name= "dde";
|
||||
echo(`\n ${out} (${file} → globalThis.${name})\n`);
|
||||
|
||||
let content= s.cat(file).toString().split(/export ?{/);
|
||||
content.splice(1, 0, `\nglobalThis.${name}= {`);
|
||||
content[2]= content[2].replace(/^(\t*)(.*) as ([^,\n]*)(,?)$/mg, "$1$3: $2$4");
|
||||
s.echo([
|
||||
`//deka-dom-el library is available via global namespace \`${name}\``,
|
||||
"(()=> {",
|
||||
"\t"+content.join("").split("\n").join("\n "),
|
||||
"})();"
|
||||
].join("\n")).to(out);
|
||||
let content= s.cat(file).toString().split(/export ?{/);
|
||||
content.splice(1, 0, `\nglobalThis.${name}= {`);
|
||||
content[2]= content[2].replace(/,(?!\n)/g, ",\n").replace(/(?<!\n)}/, "\n}").replace(/^(\t*)(.*) as ([^,\n]*)(,?)$/mg, "$1$3: $2$4");
|
||||
s.echo([
|
||||
`//deka-dom-el library is available via global namespace \`${name}\``,
|
||||
"(()=> {",
|
||||
content.join(""),
|
||||
"})();"
|
||||
].join("\n")).to(out);
|
||||
|
||||
echo("⚡ Done\n");
|
||||
}
|
||||
echo("⚡ Done\n");
|
||||
}
|
||||
})
|
||||
.parse();
|
||||
|
541
dist/dde-with-signals.js
vendored
541
dist/dde-with-signals.js
vendored
File diff suppressed because one or more lines are too long
351
dist/dde.js
vendored
351
dist/dde.js
vendored
File diff suppressed because one or more lines are too long
527
dist/esm-with-signals.js
vendored
527
dist/esm-with-signals.js
vendored
File diff suppressed because one or more lines are too long
339
dist/esm.js
vendored
339
dist/esm.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user