-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (80 loc) · 2.4 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
// define Gulp and preprocessors
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
changed = require('gulp-changed'),
imagemin = require('gulp-imagemin'),
stripDebug = require('gulp-strip-debug'),
autoprefix = require('gulp-autoprefixer'),
clean = require('gulp-clean'),
rename = require('gulp-rename'),
cssmin = require('gulp-cssmin');
// directories
var src = './assets/src/',
dest = './assets/';
// clean task
gulp.task('clean', function() {
return gulp.src([dest + 'css/*', dest + 'js/*'], {read: false})
.pipe(clean());
});
// scss task
gulp.task('scss', function() {
return sass(src + 'scss/main.scss')
.pipe(autoprefix('last 2 versions'))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(dest + 'css/'));
});
// js task
gulp.task('js', function() {
// main app js file
gulp.src(src + 'js/app.js')
.pipe(stripDebug())
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(dest + 'js/'));
});
// bower components
gulp.task('bower', function() {
// bower js components
gulp.src([
src + 'vendor/bootstrap/dist/js/bootstrap.min.js',
src + 'vendor/jquery/dist/jquery.min.js',
src + 'vendor/tether/dist/js/tether.min.js'
])
.pipe(gulp.dest(dest + 'js'));
// bower css components
gulp.src([src + 'vendor/bootstrap/dist/css/bootstrap.min.css'])
.pipe(gulp.dest(dest + 'css'));
});
// jshint task
gulp.task('jshint', function() {
gulp.src(src + 'js/app.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
// imagemin task
gulp.task('imagemin', function() {
var imgSrc = src + 'images/**/*.png',
imgDst = dest + 'images';
gulp.src(imgSrc)
.pipe(changed(imgDst))
.pipe(imagemin())
.pipe(gulp.dest(imgDst));
});
// Default Gulp run task
gulp.task('default', ['clean', 'scss', 'js', 'imagemin', 'bower']);
// watch task
gulp.task('watch', function() {
// watch Sass files
gulp.watch(src + 'scss/**/*.scss', ['scss']);
// watch JavaScript files
gulp.watch(src + 'js/app.js', ['js']);
// watch image files
gulp.watch(src + 'images/**/*.png', ['imagemin']);
});