-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
63 lines (53 loc) · 1.56 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
55
56
57
58
59
60
61
62
63
var gulp = require('gulp')
var rollup = require('rollup-stream')
var source = require('vinyl-source-stream')
var uglify = require('gulp-uglify-es').default
var del = require('del')
var rename = require('gulp-rename')
var eslint = require('gulp-eslint')
var browserSync = require('browser-sync').create()
gulp.task('clean', function () {
return del(['dist'])
})
gulp.task('lint', function () {
return gulp.src(['./src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
gulp.task('rollup', function () {
return rollup('rollup.config.js')
.pipe(source('d3-heatmap2.js'))
.pipe(gulp.dest('./dist'))
})
gulp.task('uglify', function () {
return gulp.src('./dist/d3-heatmap2.js')
.pipe(gulp.dest('./dist'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('./dist'))
})
gulp.task('style', function () {
return gulp.src('./src/heatmap.css')
.pipe(rename('d3-heatmap2.css'))
.pipe(gulp.dest('./dist'))
})
gulp.task('rollup-watch', gulp.series('rollup', function (done) {
browserSync.reload()
done()
}))
gulp.task('style-watch', gulp.series('style', function (done) {
browserSync.reload()
done()
}))
gulp.task('serve', gulp.series('lint', 'rollup', 'style', function () {
browserSync.init({
server: {
baseDir: ['examples', 'dist']
}
})
gulp.watch('./src/*.js', gulp.series('rollup-watch'))
gulp.watch('./src/*.css', gulp.series('style-watch'))
}))
gulp.task('build', gulp.series('clean', 'lint', 'rollup', 'style', 'uglify'))
gulp.task('default', gulp.series('serve'))