-
Notifications
You must be signed in to change notification settings - Fork 282
/
gulpfile.js
54 lines (49 loc) · 1.64 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
var browserify = require('browserify');
var concat = require('gulp-concat');
var del = require('del');
var gulp = require('gulp');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var vinylBuffer = require('vinyl-buffer');
var vinylSourceStream = require('vinyl-source-stream');
var polyfills = [
'./node_modules/es6-promise/dist/es6-promise.js',
'./node_modules/json3/lib/json3.js',
'./polyfills.js'
];
var sources = 'stacktrace.js';
gulp.task('dist', function() {
browserify({
entries: sources,
debug: true,
standalone: 'StackTrace'
}).bundle()
.pipe(vinylSourceStream(sources))
.pipe(gulp.dest('dist'))
.pipe(vinylBuffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
browserify({
entries: polyfills.concat(sources),
debug: true,
standalone: 'StackTrace'
}).bundle()
.pipe(vinylSourceStream('stacktrace.js'))
.pipe(vinylBuffer())
.pipe(concat(sources.replace('.js', '-with-promises-and-json-polyfills.js')))
.pipe(gulp.dest('dist'))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', del.bind(null, ['build', 'dist']));
gulp.task('default', ['clean'], function(cb) {
runSequence('dist', 'test', cb);
});