forked from thomasvaeth/instafetch.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (36 loc) · 1.09 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
'use strict';
const gulp = require('gulp');
const babelify = require('babelify');
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const eslint = require('gulp-eslint');
const rename = require('gulp-rename');
const source = require('vinyl-source-stream');
const strip = require('gulp-strip-comments');
const uglify = require('gulp-uglify');
gulp.task('lint', () => {
return gulp.src('./src/instafetch.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('browserify', () => {
return browserify('./src/instafetch.js')
.transform('babelify', {presets: ['env']})
.bundle()
.pipe(source('instafetch.js'))
.pipe(buffer())
.pipe(strip())
.pipe(gulp.dest('./dist'));
});
gulp.task('minifyScript', ['browserify'], () => {
return gulp.src('./dist/instafetch.js')
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', ['lint', 'minifyScript']);
gulp.task('watch', () => {
gulp.watch('./src/**/*.js', ['lint', 'minifyScript']);
});
gulp.task('default', ['build', 'watch']);