forked from robomx/web-dialog-alert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
32 lines (24 loc) · 935 Bytes
/
build.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
const fse = require('fs-extra')
const minify = require('@node-minify/core');
const terser = require('@node-minify/terser');
if(fse.existsSync('dist')){
fse.removeSync('dist')
}
var fileName = 'dist/webdialogalert.min.js';
fse.copySync('src','dist');
// compute original file size
const o_stats = fse.statSync(fileName.replace(".min", ""));
const originalFileSizeInBytes = o_stats.size;
console.log(originalFileSizeInBytes, 'File size of original content')
minify({
compressor: terser,
input: fileName.replace(".min", ""),
output: fileName,
callback: function(err, min) {}
});
// compute new compressed file size
const n_stats = fse.statSync(fileName);
const compressedFileSizeInBytes = n_stats.size;
console.log(compressedFileSizeInBytes, 'File size of compressed content')
// compute reduce size
console.log(100 - (compressedFileSizeInBytes / originalFileSizeInBytes * 100).toFixed(2), '% size decreased')