nix/make-bundled: add minification option
Signed-off-by: Xe <me@christine.website>
This commit is contained in:
parent
89969955be
commit
db3563f20f
|
@ -56,6 +56,7 @@
|
||||||
output = "bundled.js";
|
output = "bundled.js";
|
||||||
entrypoint = "./mod.ts";
|
entrypoint = "./mod.ts";
|
||||||
importMap = "./import_map.json";
|
importMap = "./import_map.json";
|
||||||
|
minify = true;
|
||||||
};
|
};
|
||||||
packages.bundled-wrapper = deno2nix.mkBundledWrapper {
|
packages.bundled-wrapper = deno2nix.mkBundledWrapper {
|
||||||
pname = "example-bundled-wrapper";
|
pname = "example-bundled-wrapper";
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
lockfile,
|
lockfile,
|
||||||
output ? "bundled.js",
|
output ? "bundled.js",
|
||||||
outPath ? "dist",
|
outPath ? "dist",
|
||||||
|
minify ? false,
|
||||||
entrypoint,
|
entrypoint,
|
||||||
importMap ? null,
|
importMap ? null,
|
||||||
additionalDenoFlags ? "",
|
additionalDenoFlags ? "",
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
inherit pname version entrypoint src;
|
inherit pname version entrypoint src;
|
||||||
buildInputs = with pkgs; [deno jq];
|
buildInputs = with pkgs; [ deno jq nodePackages.uglify-js ];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
export DENO_DIR="/tmp/deno2nix"
|
export DENO_DIR="/tmp/deno2nix"
|
||||||
|
@ -28,7 +29,7 @@ in
|
||||||
|
|
||||||
deno bundle \
|
deno bundle \
|
||||||
--lock="${lockfile}" \
|
--lock="${lockfile}" \
|
||||||
${
|
${
|
||||||
if importMap != null
|
if importMap != null
|
||||||
then "--import-map=\"$src/${importMap}\""
|
then "--import-map=\"$src/${importMap}\""
|
||||||
else ""
|
else ""
|
||||||
|
@ -36,6 +37,15 @@ in
|
||||||
${additionalDenoFlags} \
|
${additionalDenoFlags} \
|
||||||
"$src/${entrypoint}" \
|
"$src/${entrypoint}" \
|
||||||
"${output}"
|
"${output}"
|
||||||
|
|
||||||
|
${
|
||||||
|
if minify
|
||||||
|
then ''
|
||||||
|
mv ${output} ${output}-non-min
|
||||||
|
uglifyjs ${output}-non-min -c -m > ${output}
|
||||||
|
''
|
||||||
|
else ""
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/${outPath}
|
mkdir -p $out/${outPath}
|
||||||
|
|
Loading…
Reference in a new issue