-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathuglify.nu
34 lines (31 loc) · 904 Bytes
/
uglify.nu
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
def "uglify out" [path: string] {
($path | str substring ..-4) + ".min.js"
}
# Uglify a given file, using swc and uglify-js
def uglify [path: string] {
let min_path = uglify out $path;
print $"Processing ($path) ...";
print $"Calling swc on ($path) ...";
swc $path -o $min_path;
print $"Calling uglify-js on ($min_path)";
uglifyjs --no-module --webkit $min_path -o $min_path -m;
print "Finished process.";
}
# Uglify all files
def "uglify all" [
path: string,
-d, --delete,
] {
if $d {
uglify clear $path;
}
let files = ls $path | where { not ($in.name | str contains "min") };
$files | each { |row| uglify $row.name };
echo "Finished.";
}
# Remove uglified file
def "uglify clear" [path: string] {
let files = ls $path | where { $in.name | str contains "min" };
$files | each { |row| rm $row.name };
echo "Finished.";
}