forked from zsxeee/watermark-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
24 lines (20 loc) · 774 Bytes
/
index.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
const minify = require('html-minifier').minify;
const fs = require("fs");
const Base64 = require('js-base64').Base64;
fs.readFile('./watermark-helper.html', 'utf-8', (e, data) => {
if (e) throw Error(`Read failed: ${e.message}`);
let result = minify(data, {
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
removeAttributeQuotes: true,
sortAttributes: true
});
fs.writeFile('./watermark-helper.min.html', result, 'utf-8', (e) => {
if (e) throw Error(`Write failed: ${e.message}`);
});
fs.writeFile('./data-link.txt', 'data:text/html;base64,' + Base64.encode(result), (e) => {
if (e) throw Error(`Write failed: ${e.message}`);
})
});