-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgulpfile.js
46 lines (39 loc) · 1.07 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
/* jshint node: true */
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var merge = require('merge-stream');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var del = require('del');
gulp.task('build', function build() {
var raw = browserify({
entries: './lib/scratchcard.js',
standalone: 'Scratchcard',
debug: true
});
var standalone = browserify({
entries: './lib/standalone.js',
standalone: 'Scratchcard',
debug: true
});
var bundles = [
raw.bundle().pipe(source('scratchcard.js')),
standalone.bundle().pipe(source('scratchcard-standalone.js'))
];
return merge(bundles)
.pipe(gulp.dest('dist'))
.pipe(rename({suffix: '.min'}))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function clean() {
return del('dist');
});
gulp.task('default', ['build']);