forked from tympanix/pattern-lock-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (38 loc) · 1.19 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
const gulp = require('gulp');
const browsersync = require('browser-sync').create();
const uglify = require('gulp-uglify');
const useref = require('gulp-useref');
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const gulpif = require('gulp-if');
const cleancss = require('gulp-clean-css');
gulp.task('serve', function() {
browsersync.init({
server: {
baseDir: "./"
}
});
});
gulp.task('reload', function () {
browsersync.reload()
});
gulp.task('build', ['build:docs', 'build:dist'])
gulp.task('build:docs', function() {
return gulp.src('index.html')
.pipe(useref())
.pipe(gulpif('patternlock.js', babel({presets: ['env']})))
.pipe(gulp.dest('docs'))
})
gulp.task('build:dist', function() {
return gulp.src('patternlock.*')
.pipe(gulpif('*.js', babel({presets: ['env']})))
.pipe(gulp.dest('dist'))
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', cleancss()))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist'))
})
gulp.task('watch', function () {
gulp.watch(['./*.html', './*.css', './*.js'], ['reload']);
});
gulp.task('default', ['serve', 'watch']);