forked from KingSora/OverlayScrollbars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
75 lines (70 loc) · 2.13 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const fs = require('fs');
const sh = require('shelljs');
const chalk = require('chalk');
const gulp = require('gulp');
const uglify = require('uglify-js');
const csso = require('csso');
const uglifyFiles = [
{
src: './js/OverlayScrollbars.js',
dest: './js/OverlayScrollbars.min.js',
},
{
src: './js/jquery.overlayScrollbars.js',
dest: './js/jquery.overlayScrollbars.min.js',
}
];
const cssoFiles = [
{
src: './css/OverlayScrollbars.css',
dest: './css/OverlayScrollbars.min.css',
}
];
sh.echo(chalk.cyanBright('Start building:'));
gulp.task('uglify', function (done) {
uglifyFiles.forEach((file) => {
if (sh.test('-f', file.src)) {
sh.echo(chalk.yellowBright('uglify: ') + chalk.greenBright(`${file.src} → ${file.dest}`));
sh.ShellString(uglify.minify(fs.readFileSync(file.src, 'utf-8'), {
ie8: true,
compress: {
ie8: true
},
mangle: {
ie8: true,
properties: {
'regex': /^_/
}
},
output: {
ie8: true,
beautify: false,
comments: /@license|@preserve|^!/,
indent_level: 4,
indent_start: 0,
quote_style: 0
}
}).code).to(file.dest);
}
else {
sh.echo(chalk.redBright(`${file.src} not found!`));
}
});
done();
});
gulp.task('csso', function (done) {
cssoFiles.forEach((file) => {
if (sh.test('-f', file.src)) {
sh.echo(chalk.yellowBright('csso: ') + chalk.greenBright(`${file.src} → ${file.dest}`));
sh.ShellString(csso.minify(fs.readFileSync(file.src, 'utf-8'), {
restructure: false,
comments: 'first-exclamation'
}).css).to(file.dest);
}
else {
sh.echo(chalk.redBright(`${file.src} not found!`));
}
});
done();
});
gulp.parallel('uglify', 'csso')();