-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
executable file
·48 lines (42 loc) · 1.2 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
'use strict';
var gulp = require('gulp');
var imagepack = require('./');
var filename = 'pack';
gulp.task('pack', function() {
// return gulp.src(['./example/images/**/*'])
return gulp.src(['./example/images/**/*.{gif,jpg,png,webp}'])
.pipe(imagepack.pack({
name: filename,
verbose: true
}))
.pipe(gulp.dest('./example/packs'));
});
gulp.task('unpack', function() {
return gulp.src(['./example/packs/' + filename + '.bin'])
.pipe(imagepack.unpack({
verbose: true
}))
.pipe(gulp.dest('./unpacked'));
});
gulp.task('bundle', function() {
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var gutil = require('gulp-util');
return browserify({
entries: './src/imagepack.js',
standalone: 'Imagepack',
debug: true
})
.bundle()
.on('error', gutil.log)
.pipe(source('imagepack.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/'))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('./dist/'));
});