-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
56 lines (49 loc) · 1.37 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
/*jslint node: true, nomen: true */
"use strict";
var gulp = require('gulp'),
rimraf = require('gulp-rimraf'),
rename = require('gulp-rename'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
extractor = require('gulp-extract-sourcemap'),
minifyjs = require('gulp-uglify');
gulp.task('clean', function () {
return gulp.src('./dist/*', {read: false, dot: true}).pipe(rimraf({ force: true }));
});
var expose = {
'window': 'window',
};
gulp.task('almost.js', function () {
return browserify({
entries: './global.js',
debug: true,
})
.transform('exposify', {
expose: expose
})
.bundle()
.pipe(source('almost.js'))
.pipe(buffer())
.pipe(extractor({
basedir: __dirname,
fakeFix: true
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('almost.min.js', function () {
return browserify({
entries: './global.js',
debug: false,
})
.transform('exposify', {
expose: expose
})
.bundle()
.pipe(source('almost.min.js'))
.pipe(buffer())
.pipe(minifyjs())
.pipe(gulp.dest('./dist'));
});
gulp.task('build', gulp.parallel('almost.js', 'almost.min.js'));
gulp.task('default', gulp.series('clean', 'build'));