-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathgulpfile.js
76 lines (64 loc) · 2.32 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
64
65
66
67
68
69
70
71
72
73
74
75
76
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
svgmin = require('gulp-svgmin'),
htmlmin = require('gulp-htmlmin'),
del = require('del');
gulp.task('styles', function() {
return gulp.src('media/css/home.css')
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('media/dist/assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('media/dist/assets/css'))
.pipe(notify({ message: 'Styles task complete' }));
});
gulp.task('scripts', function() {
return gulp.src('media/js/views/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('home.js'))
.pipe(gulp.dest('media/dist/assets/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('media/dist/assets/js'))
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('images', function() {
return gulp.src('media/img/**/*')
.pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
.pipe(gulp.dest('media/dist/assets/img'))
.pipe(notify({ message: 'Images task complete' }));
});
// Not running right now because I was having trouble, revisit - GW
gulp.task('svg', function() {
return gulp.src('media/img/examples/us_exports_2012.svg')
.pipe(svgmin())
.pipe(gulp.dest('media/dist/assets/img'))
});
gulp.task('html', function() {
gulp.src('html/home.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('media/dist'))
});
gulp.task('clean', function(cb) {
del(['media/dist/assets/css', 'media/dist/assets/js', 'media/dist/assets/img'], cb)
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'images', 'html');
});
gulp.task('watch', function() {
// Watch .scss files
gulp.watch('media/css/home.css', ['styles']);
// Watch .js files
gulp.watch('media/js/views/*.js', ['scripts']);
// Watch image files
gulp.watch('media/img/**/*', ['images']);
});