forked from maxisix/maxisix-gulp-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·112 lines (70 loc) · 3.07 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
111
112
/*******************************************************************************
DEPENDENCIES
*******************************************************************************/
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
notify = require('gulp-notify'),
stylish = require('jshint-stylish'),
imagemin = require('gulp-imagemin');
/*******************************************************************************
FILE DESTINATIONS (RELATIVE TO ASSSETS FOLDER)
*******************************************************************************/
var target = {
sass_src : './assets/sass/*.scss', // all sass files
css_dest : './assets/css', // where to put minified css
js_src : './assets/js/*.js', // all js files
js_dest : './assets/js/min', // where to put minified js
img_src : './assets/images/*.{png,jpg,gif}', // all img files
img_dest : './assets/images/min' // where to put minified img
};
/*******************************************************************************
SASS TASK
*******************************************************************************/
gulp.task('styles', function() {
return gulp.src(target.sass_src)
.pipe(sass({
includePaths: ['./assets/sass'],
outputStyle: 'expanded',
errLogToConsole: true
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest(target.css_dest))
.pipe(notify('Styles task completed'));
});
/*******************************************************************************
JS TASK
*******************************************************************************/
gulp.task('scripts', function() {
return gulp.src(target.js_src)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest(target.js_dest))
.pipe(notify('Scripts task completed'));
});
/*******************************************************************************
IMAGES TASK
*******************************************************************************/
gulp.task('images', function() {
return gulp.src(target.img_src)
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(notify('Images task completed'))
.pipe(gulp.dest(target.img_dest));
});
/*******************************************************************************
DEFAULT TASK
*******************************************************************************/
gulp.task('default', ['styles','scripts','images'], function() {
});
/*******************************************************************************
WATCH TASK
*******************************************************************************/
gulp.task('watch', function() {
gulp.watch(target.sass_src, ['styles']); // Watch .scss files
gulp.watch(target.js_src, ['scripts']); // Watch .js files
});