-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.babel.js
75 lines (63 loc) · 1.67 KB
/
gulpfile.babel.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
import packageJSON from './package.json';
import gulp from 'gulp';
import babel from 'gulp-babel';
import plumber from 'gulp-plumber';
import header from 'gulp-header';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import sourcemaps from 'gulp-sourcemaps';
import browserSync from 'browser-sync';
import jade from 'gulp-jade';
const reload = browserSync.reload;
// HEADER
const attribution = [
'/*!',
' * lazy-blur.js <%= pkg.version %> - <%= pkg.description %>',
' * Copyright (c) ' + new Date().getFullYear() + ' <%= pkg.author %> - <%= pkg.homepage %>',
' * License: <%= pkg.license %>',
' */'
].join('\n');
// JS
gulp.task('js', () => {
return gulp.src('src/lazy-blur.js')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(header(attribution, { pkg: packageJSON }))
.pipe(gulp.dest('./dist'))
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename((path) => {
path.basename += '.min';
}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist'));
});
// SERVER
gulp.task('server', () => {
browserSync({
open: 'external',
browser: 'google-chrome',
notify: false,
ghostMode: {
clicks: false,
scroll: false,
forms: false
},
scrollThrottle: 500,
startPath: './dist/demo.html',
server: ''
});
});
// DEMO
gulp.task('demo', () => {
return gulp.src('demo/demo.jade')
.pipe(plumber())
.pipe(jade({pretty: true}))
.pipe(gulp.dest('./dist'));
});
gulp.task('dev', ['default'], () => {
gulp.watch('src/lazy-blur.js', ['js', reload]);
gulp.watch('demo/demo.jade', ['demo', reload]);
});
gulp.task('default', ['js', 'server']);