forked from udacity/frontend-nanodegree-mobile-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (72 loc) · 2.18 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
77
78
79
80
81
82
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var cssmin = require('gulp-cssmin');
var uncss = require('gulp-uncss');
var htmlmin = require('gulp-htmlmin');
var inlinesource = require('gulp-inline-source');
// Lint Task
gulp.task('lint', function() {
return gulp.src('source/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('source/js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('production'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('production/js'));
});
// Images
gulp.task('images', function () {
return gulp.src('source/img/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('production/img'));
});
// Images
gulp.task('images2', function () {
return gulp.src('source/views/images/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('production/views/images'));
});
// CSS
gulp.task('css', function () {
gulp.src('source/css/*.css')
.pipe(uncss({
html: ['source/index.html', 'source/views/pizza.html']
}))
.pipe(cssmin())
//.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('production/css'));
});
gulp.task('html', function() {
return gulp.src('source/*.html')
.pipe(inlinesource())
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('production/'))
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('js/*.js', ['lint', 'scripts']);
gulp.watch('css/*.css', ['css']);
gulp.watch('*.html', ['html']);
});
// Default Task
gulp.task('default', ['lint', 'scripts', 'watch', 'images', 'images2', 'css', 'html']);