-
Notifications
You must be signed in to change notification settings - Fork 3
/
minify.js
37 lines (34 loc) · 818 Bytes
/
minify.js
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
const fs = require('fs');
const minify = require('@node-minify/core');
const terser = require('@node-minify/terser');
const noCompress = require('@node-minify/no-compress');
const package = require('./package.json');
let version = "v" + package.version;
let output = `dist/HabiticaMagic-${version}.js`;
let minOutput = `dist/HabiticaMagic-${version}.min.js`;
let files = [
'src/header.js',
'src/HabiticaUserTasksManager.js',
'src/HabiticaUser.js',
'src/HabiticaAPIManager.js'
];
let preamble = fs.readFileSync('src/header.js', 'utf8');
// combine all the files
minify({
compressor: noCompress,
input: files,
output: output
})
// Run the minifier
.then(function(min) {
minify({
compressor: terser,
input: output,
output: minOutput,
options: {
output: {
preamble: preamble
}
}
});
});