-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
48 lines (41 loc) · 1.33 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
print = require('gulp-print'),
babel = require('gulp-babel'),
del = require('del');
var CacheBuster = require('gulp-cachebust');
var cachebust = new CacheBuster();
gulp.task('clean', function(cb) {
del(['dist'], cb);
});
gulp.task('build-css', function() {
return gulp.src('./styles/**/*')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(cachebust.resources())
.pipe(concat('styles.css'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/styles'));
});
// Why isn't there a cachebust in build-js?
gulp.task('build-js', function() {
return gulp.src('./js/**/*')
.pipe(sourcemaps.init())
.pipe(print())
.pipe(babel({ presets: ['es2015'] }))
.pipe(concat('bundle.js'))
// .pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/js'));
});
gulp.task('build', ['clean', 'build-css', 'build-js'], function() {
return gulp.src('index.html')
.pipe(cachebust.references())
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function() {
return gulp.watch(['./index.html', './styles/**/*', './js/**/*', './views/**/*'], ['build']);
});