This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
100 lines (84 loc) · 2.42 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var gulp = require('gulp');
var gutil = require('gulp-util');
var clean = require('gulp-clean');
var changed = require('gulp-changed');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var imagemin = require('gulp-imagemin');
var cssmin = require('gulp-cssmin');
var jshint = require('gulp-jshint');
var summary = require('jshint-summary');
var paths = {
buildDir: 'public/dist',
assets: [
'public/images/**',
'public/projects/**'
],
scripts: [
'public/scripts/vendor/modernizr.custom.js',
'public/scripts/vendor/spin.min.js',
'public/scripts/vendor/background-slideshow/js/jquery.imagesloaded.min.js',
'public/scripts/vendor/background-slideshow/js/cbpBGSlideshow.js',
'public/scripts/vendor/ui-utils-0.1.1/ui-utils.js'
],
stylesheets: [
'public/scripts/vendor/background-slideshow/css/component.css',
'public/css/ng-animate.css',
'public/css/reset.css',
'public/css/fonts.css',
'public/css/app.css'
]
};
gulp.task('default', ['compress']);
gulp.task('compress', ['scripts', 'assets', 'css'], function() {
gutil.log(gutil.colors.green('Files compressed'));
});
// Clean out build directory
gulp.task('clean', function() {
return gulp.src(paths.buildDir, { read: false }).pipe(clean());
});
// Watch for changes
gulp.task('watch', function() {
gutil.log('gulp:watch task running...');
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.assets, ['assets']);
gulp.watch(paths.stylesheets, ['css']);
});
// Lint scripts
gulp.task('lint', function() {
gulp.src('scripts/app.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-summary', {
verbose: true,
reasonCol: 'cyan,bold',
codeCol: 'green'
}));
});
// Minify scripts
gulp.task('scripts', ['lint'], function() {
gulp.src(paths.scripts)
.pipe(uglify())
.pipe(concat('lukeburroughs.min.js'))
.pipe(gulp.dest(paths.buildDir));
});
// Minify image assets and maintain file structure by setting base
// Todo: PNG's
gulp.task('assets', function() {
return gulp.src(paths.assets, { base: 'public' })
// Only compress files which have been modified
.pipe(changed(paths.buildDir))
.pipe(imagemin({
progressive: true,
svgoPlugins: [{
removeViewBox: false
}]
}))
.pipe(gulp.dest(paths.buildDir));
});
// Minify stylesheets
gulp.task('css', function() {
gulp.src(paths.stylesheets)
.pipe(cssmin())
.pipe(concat('lukeburroughs.min.css'))
.pipe(gulp.dest(paths.buildDir));
});