HTML5Helper: use bundled terser, but also add optional -npx flag to use npx version

This commit is contained in:
Josh Tynjala
2023-05-16 12:45:29 -07:00
parent 802472cee6
commit 763b982bd1
151 changed files with 99537 additions and 2 deletions

View File

@@ -166,8 +166,38 @@ class HTML5Helper
if (project.targetFlags.exists("terser"))
{
var executable = "npx";
var terser = "terser";
if (!project.targetFlags.exists("npx")) {
var suffix = switch (System.hostPlatform)
{
case WINDOWS: "-windows.exe";
case MAC: "-mac";
case LINUX: "-linux";
default: return false;
}
if (suffix == "-linux")
{
if (System.hostArchitecture == X86)
{
suffix += "32";
}
else
{
suffix += "64";
}
}
var templatePaths = [
Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end)
].concat(project.templatePaths);
executable = System.findTemplate(templatePaths, "bin/node/node" + suffix);
terser = System.findTemplate(templatePaths, "bin/node/terser/bin/terser");
}
var args = [
"terser",
terser,
sourceFile,
"-c",
"-m",
@@ -181,7 +211,7 @@ class HTML5Helper
args.push('content=\'${sourceFile}.map\'');
}
System.runCommand("", "npx", args);
System.runCommand("", executable, args);
}
else if (project.targetFlags.exists("yui"))
{