-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·110 lines (100 loc) · 3.05 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
101
102
103
104
105
106
107
108
109
110
// Load Gulp
var gulp = require('gulp'),
gutil = require('gulp-util'),
imageResize = require('gulp-image-resize'),
plugins = require('gulp-load-plugins')({
rename: {
'gulp-live-server': 'serve'
}
});
// Start Watching: Run "gulp"
gulp.task('default', ['watch']);
// Run "gulp server"
gulp.task('server', ['serve', 'watch']);
// Minify jQuery Plugins: Run manually with: "gulp squish-jquery"
gulp.task('squish-jquery', function () {
return gulp.src('assets/js/libs/**/*.js')
.pipe(plugins.uglify({
output: {
'ascii_only': true
}
}))
.pipe(plugins.concat('jquery.plugins.min.js'))
.pipe(gulp.dest('build'));
});
// Minify Javascript Plugins: Run manually with: "gulp squish-js"
gulp.task('squish-js', function () {
return gulp.src('assets/js/libs/**/*.js')
.pipe(plugins.uglify({
output: {
'ascii_only': true
}
}))
.pipe(plugins.concat('plugins.min.js'))
.pipe(gulp.dest('build'));
});
// re-size images: Run manually with: "gulp resize-img"
gulp.task('resize-img', function () {
gulp.src('img/portfolio/original/*')
.pipe(imageResize({
width : 700,
height : 500,
crop : true,
upscale : false
}))
.pipe(gulp.dest('img/portfolio'));
});
// Minify Custom JS: Run manually with: "gulp build-js"
gulp.task('build-js', function () {
return gulp.src('assets/js/*.js')
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('jshint-stylish'))
.pipe(plugins.uglify({
output: {
'ascii_only': true
}
}))
.pipe(plugins.concat('scripts.min.js'))
.pipe(gulp.dest('build'));
});
// Less to CSS: Run manually with: "gulp build-css"
gulp.task('build-css', function () {
return gulp.src('assets/less/*.less')
.pipe(plugins.plumber())
.pipe(plugins.less())
.on('error', function (err) {
gutil.log(err);
this.emit('end');
})
.pipe(plugins.autoprefixer({
browsers: [
'> 1%',
'last 2 versions',
'firefox >= 4',
'safari 7',
'safari 8',
'IE 8',
'IE 9',
'IE 10',
'IE 11'
],
cascade: false
}))
.pipe(plugins.cssmin())
.pipe(gulp.dest('build')).on('error', gutil.log);
});
// Default task
gulp.task('watch', function () {
gulp.watch('assets/js/libs/**/*.js', ['squish-jquery']);
gulp.watch('assets/js/*.js', ['build-js']);
gulp.watch('assets/less/**/*.less', ['build-css']);
});
// Folder "/" serving at http://localhost:8888
// Should use Livereload (http://livereload.com/extensions/)
gulp.task('serve', function () {
var server = plugins.serve.static('/', 8888);
server.start();
gulp.watch(['build/*'], function (file) {
server.notify.apply(server, [file]);
});
});