Skip to content

Commit 62fb449

Browse files
committed
using closure compiler to optimize output of ghcjs
1 parent b51d99e commit 62fb449

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

ghcjs/currency-converter/default.nix

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ in rec {
3434
nix-build -A releaseDer
3535
rm -rf ./dist/latest
3636
mkdir -p ./dist/latest
37-
${safeCopy} ./result/bin/app.jsexe/* ./dist/latest
37+
${safeCopy} ./result/* ./dist/latest
3838
)
3939
'';
4040
};
@@ -59,23 +59,38 @@ in rec {
5959
-l txt -y 2024 -o Functora mit > ${repo}/LICENSE
6060
'';
6161
};
62-
releaseDer = app.overrideAttrs (_: rec {
63-
postInstall = ''
64-
mkdir -p $out/bin/app.jsexe/static
65-
cp -R ${./static}/* $out/bin/app.jsexe/static
66-
cp ${./static}/favicon.ico $out/bin/app.jsexe/favicon.ico
67-
cp ${readmeDer}/readme.html $out/bin/app.jsexe/
68-
cp ${licenseDer}/license.html $out/bin/app.jsexe/
69-
cp ${privacyDer}/privacy.html $out/bin/app.jsexe/
62+
releaseDer = functora-pkgs.stdenv.mkDerivation {
63+
name = "releaseDer";
64+
dontBuild = true;
65+
dontUnpack = true;
66+
installPhase = ''
67+
mkdir -p $out/static
68+
cp ${./static}/*.png $out/static/
69+
cp ${./static}/*.css $out/static/
70+
cp ${./static}/*.woff2 $out/static/
71+
cp ${./static}/*.ico $out/
72+
cp ${./static}/*.webmanifest $out/
73+
cp ${readmeDer}/readme.html $out/
74+
cp ${licenseDer}/license.html $out/
75+
cp ${privacyDer}/privacy.html $out/
76+
echo '<!doctype html><html><head><script language="javascript" src="all.js"></script></head><body></body></html>' > $out/index.html
77+
${functora-pkgs.closurecompiler}/bin/closure-compiler \
78+
--jscomp_off=checkVars \
79+
--compilation_level ADVANCED_OPTIMIZATIONS \
80+
--externs ${app}/bin/app.jsexe/all.js.externs \
81+
--externs ${./static}/material-components-web.min.js \
82+
--externs ${./static}/material-components-web-elm.min.js \
83+
--js ${app}/bin/app.jsexe/all.js \
84+
--js_output_file $out/all.js
7085
'';
71-
});
86+
};
7287
releaseStableDer = functora-pkgs.stdenv.mkDerivation {
7388
name = "releaseStableDer";
7489
dontBuild = true;
7590
dontUnpack = true;
7691
installPhase = ''
7792
mkdir -p $out/${vsn}
78-
cp -R ${releaseDer}/bin/app.jsexe/* $out/${vsn}
93+
cp -R ${releaseDer}/* $out/${vsn}
7994
echo '<!doctype html><html><head><meta http-equiv="Refresh" content="0; url=${vsn}/index.html"></head><body></body></html>' > $out/index.html
8095
echo "Version ${vsn} has been released!"
8196
'';

0 commit comments

Comments
 (0)