-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
56 lines (49 loc) · 1.08 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Requires
var fs = require('fs');
var UglifyJS = require('uglify-js');
var UglifyCSS = require('uglifycss');
// Vars
var scriptFileName = 'progress-steps';
var dir = __dirname;
var sourceFolder = dir + '/src/';
var distFolder = dir + '/dist/';
// JS Minification
var code = fs.readFileSync(sourceFolder + scriptFileName + '.js', 'utf8');
var uglifiedCode = UglifyJS.minify(code, {
mangle: {
toplevel: true,
},
nameCache: {},
}).code;
// CSS Minification
var css = fs.readFileSync(sourceFolder + scriptFileName + '.css', 'utf8');
var uglifiedCss = UglifyCSS.processString(css, {
});
// Create dist folder if not exists
if (!fs.existsSync(distFolder)) {
fs.mkdirSync(distFolder);
}
// Create the javascript
fs.writeFile(
distFolder + scriptFileName + '.min.js',
uglifiedCode,
function (err) {
if (err) {
console.log(err);
} else {
console.log('Minified javascript saved');
}
}
);
// Create the CSS
fs.writeFile(
distFolder + scriptFileName + '.min.css',
uglifiedCss,
function (err) {
if (err) {
console.log(err);
} else {
console.log('Minified css saved');
}
}
);