-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·140 lines (123 loc) · 4.36 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*------------------------------------*\
::Variables
\*------------------------------------*/
/*------------------------------------*\
::Plugins
\*------------------------------------*/
var gulp = require('gulp');
var stops = require('pipe-error-stop')
var browserSync = require('browser-sync');
var uglify = require('gulp-uglifyjs');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var compass = require('gulp-compass');
var prefix = require('gulp-autoprefixer');
var svg = require('gulp-svg-sprite');
var shell = require('gulp-shell');
var reload = browserSync.reload;
/*------------------------------------*\
::Configuration
\*------------------------------------*/
var config = require('./zen-config.js');
/*------------------------------------*\
::Task Definitions
\*------------------------------------*/
//css
gulp.task('css', function() {
gulp.src(config.sass.src+'*.scss')
.pipe(stops(compass({
sourcemap: true,
quiet: true,
css: config.sass.dest,
sass: config.sass.src,
image: config.sass.src+'../images',
style: 'compressed',
require: ['sass-globbing']
}), {
eachErrorCallback: function(){
console.log('css task failure');
// browserSync.notify("SASS Compilation Error");
// browserSync.reload();
}
}))
.pipe(prefix('last 2 version', 'ie 10', 'ie 9'))
.pipe(browserSync.stream({injectChanges:true}))
.pipe(gulp.dest(config.sass.dest));
});
//kss (knyle style sheets)
gulp.task('kss', function() {
return gulp.src('')
.pipe(shell([
'./node_modules/.bin/kss-node',
'--source '+config.sass.src,
'--destination '+config.sass.dest+'styleguide/',
'--css ../styleguide-settings.css',
'--css ../style.css',
'--js ../styleguide-settings/jquery.1.10.1.min.js',
'--js ../styleguide-settings/styleguide.js',
'--title "Styleguide"'
].join(' ')));
});
//js
for(var key in config.js) {
gulp.task('js-'+key, function() {
var key = this.seq[0].split('-')[1];
var destParts = config.js[key].dest.split('/');
var destFile = destParts.pop();
var destPath = destParts.join('/') + '/';
gulp.src(config.js[key].src)
//.pipe(jshint())
//.pipe(jshint.reporter('default'))
.pipe(stops(concat(destFile), {
eachErrorCallback: function(){
//browserSync.notify("JavaScript Compilation Error");
console.log('js task failure');
}
}))
.pipe(gulp.dest(destPath))
.pipe(browserSync.reload({stream:true}));
});
}
//svg
for(var key in config.svg) {
gulp.task('svg-'+key, function() {
var key = this.seq[0].split('-')[1];
gulp.src(config.svg[key].src)
.pipe(svg({
mode: {
inline: true,
symbol: true
}
}))
.pipe(gulp.dest(config.svg[key].dest));
});
}
/*------------------------------------*\
::Watch
\*------------------------------------*/
//generic watch
gulp.task('watch', function() {
// browsersync proxy
// browserSync({
// proxy: config.url.root,
// open: false,
// snippetOptions: {
// whitelist: ['/sites/'+config.site.client+'/'+config.site.proj+'/wp-admin/admin-ajax.php'], // whitelist checked first
// blacklist: ['/sites/'+config.site.client+'/'+config.site.proj+'/wp-admin/**']
// }
// });
//css watch
gulp.watch(config.sass.src+'**/*.scss', ['css']);
//kss watch
gulp.watch(config.sass.dest+'/*.css', ['kss']);
//js watches
for(var key in config.js){
gulp.watch(config.js[key].src, ['js-'+key]);
}
// general file changes
gulp.watch(config.watch.src).on('change', browserSync.reload);
});
/*------------------------------------*\
::Task Combinations
\*------------------------------------*/
gulp.task('default', ['watch']);