-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.js
54 lines (48 loc) · 1.49 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 gulp = require('gulp');
var babel = require('gulp-babel');
var eslint = require('gulp-eslint');
var uglify = require('gulp-uglify');
var wrapUMD = require('gulp-wrap-umd');
var browserSync = require('browser-sync').create();
var friendlyFormatter = require("eslint-friendly-formatter");
gulp.task('compile', function() {
return gulp.src('src/canvas-compress.js')
.pipe(babel({
presets: ['es2015', 'stage-0']
}))
.pipe(wrapUMD({
exports: 'CanvasCompress',
namespace: 'CanvasCompress',
deps: [{
name: 'exif-js',
globalName: 'EXIF',
paramName: 'EXIF'
}]
}))
.pipe(gulp.dest('build/'))
.pipe(browserSync.stream());
});
gulp.task('lint', function() {
return gulp.src('src/canvas-compress.js')
.pipe(eslint())
.pipe(eslint.format(friendlyFormatter));
});
gulp.task('serve', ['compile', 'lint'], function() {
browserSync.init({
server: {
baseDir: 'test',
routes: {
'/build': 'build',
'/bower_components': 'bower_components'
}
}
});
gulp.watch('src/canvas-compress.js', ['compile', 'lint']);
gulp.watch('test/*.*').on('change', browserSync.reload);
});
gulp.task('dist', ['compile', 'lint'], function() {
return gulp.src('build/*.js')
.pipe(uglify())
.pipe(gulp.dest('dist/'))
});
gulp.task('default', ['serve']);