-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (46 loc) · 1.23 KB
/
gulpfile.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
import { rollup } from 'rollup'
import resolve from '@rollup/plugin-node-resolve'
import gulp from 'gulp'
import rename from 'gulp-rename'
import { minify } from 'rollup-plugin-esbuild-minify';
import { exec } from 'child_process';
import fs from 'fs';
/*
* javascript
*/
function minify_file(file, name, args) {
let {
do_minify = true,
output_dir = './libs',
} = args ?? {};
let plugins = [resolve()];
if (do_minify) {
plugins.push(minify());
}
return rollup({
input: file,
plugins: plugins,
}).then(bundle => {
return bundle.write({
dir: output_dir,
format: 'iife',
name: name,
});
});
}
// minify marked
gulp.task('minify-marked', () => minify_file('js/marked.js', 'marked'));
// minify codemirror
gulp.task('minify-codemirror', () => minify_file('js/codemirror.js', 'cm'));
// minify mathjax
gulp.task('minify-mathjax', () => gulp.src(['node_modules/mathjax/es5/tex-svg.js'])
.pipe(rename('mathjax.js'))
.pipe(gulp.dest('./libs'))
);
// minify all
gulp.task('minify', gulp.parallel('minify-marked', 'minify-codemirror', 'minify-mathjax'));
/*
* build
*/
// build all
gulp.task('build', gulp.parallel('minify'));