-
Notifications
You must be signed in to change notification settings - Fork 0
/
minify.nix
61 lines (59 loc) · 1.43 KB
/
minify.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let
reflex-platform = import ./reflex-platform {};
pkgs = reflex-platform.nixpkgs;
app = (import ./. {}).ghcjs.edit-log-editor;
html =
let
index =
pkgs.writeText "index.html" ''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script language="javascript" src="all.min.js"></script>
</head>
<body>
</body>
</html>
'';
in
pkgs.stdenv.mkDerivation {
name = "html";
unpackPhase = "true";
buildPhase = "true";
installPhase = ''
mkdir -p $out
cp ${index} $out/index.html
'';
};
js =
pkgs.stdenv.mkDerivation {
name = "js";
src = app;
buildInputs = [
pkgs.closurecompiler
];
buildPhase = ''
cd bin/editor.jsexe
closure-compiler \
--externs "${reflex-platform.ghcjsExternsJs}" \
-O ADVANCED \
-W QUIET \
--jscomp_warning=checkVars \
--create_source_map="all.js.map" \
--source_map_format=V3 \
--js_output_file="all.min.js" \
all.js
ls -lh all.min.js
echo "//# sourceMappingURL=all.js.map" >> all.min.js
'';
installPhase = ''
mkdir -p $out
cp all.js all.min.js all.js.map $out
'';
};
in
pkgs.symlinkJoin {
name = "minified";
paths = [ html js ];
}