-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
38 lines (35 loc) · 1 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
const gulp = require('gulp');
const pump = require('pump');
const replace = require('gulp-replace');
const rename = require('gulp-rename');
const terser = require('gulp-terser');
const umd = require('gulp-umd');
exports['build-universal-module'] = (done) => {
pump([
gulp.src('./src/main.js'),
umd({
templateName: 'amdNodeWeb',
exports: (file) => 'isset',
namespace: (file) => 'isset',
}),
terser({
keep_fnames: /^isset$/
}),
rename('module.umd.js'),
gulp.dest('./dist/')
], done);
}
exports['build-for-web'] = (done) => {
pump([
gulp.src('./src/main.js'),
replace(/^function/, 'window.isset = function'),
terser({
keep_fnames: /^isset$/
}),
rename('isset.min.js'),
gulp.dest('./dist/')
], done);
}
exports['build'] = gulp.parallel(exports['build-universal-module'], exports['build-for-web']);
exports['watch'] = () => gulp.watch('./src/main.js', exports['build']);
exports['default'] = gulp.series(exports['build'], exports['watch']);