-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
214 lines (180 loc) · 4.45 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/**
* Gulp tasks for automating our compile and build process.
*
* @package Hello Pro 3
* @author The brandiD
* @link https://thebrandiD.com
* @license GPL-2.0+
* @version 3.0
*/
'use strict';
var gulp = require('gulp'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
del = require('del'),
pxtorem = require('postcss-pxtorem'),
// Utilities
rename = require('gulp-rename'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
gutil = require('gulp-util'),
zip = require('gulp-zip'),
wpPot = require('gulp-wp-pot');
/*************
* Utilities
************/
/**
* Error handling
*
* @function
*/
function handleErrors() {
var args = Array.prototype.slice.call(arguments);
notify.onError({
title: 'Task Failed [<%= error.message %>',
message: 'See console.',
sound: 'Sosumi' // See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults
}).apply(this, args);
gutil.beep(); // Beep 'sosumi' again
// Prevent the 'watch' task from stopping
this.emit('end');
}
/*************
* CSS Tasks
************/
/**
* PostCSS Task Handler
*/
gulp.task('postcss', ['clean'], function() {
return gulp.src(['./src/**/*.css'])
// Error handling
.pipe(plumber({
errorHandler: handleErrors
}))
// Wrap tasks in a sourcemap
// .pipe(sourcemaps.init())
//
// .pipe(sass({
// includePaths: [],
// errLogToConsole: true,
// outputStyle: 'expanded' // Options: nested, expanded, compact, compressed
// }))
.pipe(postcss([
// postcssSVG({
// paths: ['./images']
// }),
pxtorem({
replace: false,
propList: ['font-size'],
mediaQuery: false,
rootValue: 10
}),
autoprefixer({
browsers: ['last 2 versions']
})
]))
// .pipe(sourcemaps.write())
.pipe(gulp.dest('.'))
// .pipe(browserSync.stream())
.pipe(notify({
message: 'PostCSS is done.'
}));
});
// gulp.task('csssvg', function() {
// return gulp.src('style.css').pipe(
// postcss([
// require('postcss-svg-fragments')({ /* options */ })
// ])
// ).pipe(
// gulp.dest('.')
// ).pipe(notify({
// message: 'Postcss SVG fragments are built.'
// }))
//
//
// });
// gulp.task('css:minify', ['postcss'], function() {
// return gulp.src('style.css')
// // Error handling
// .pipe(plumber({
// errorHandler: handleErrors
// }))
// .pipe(cssMinify({
// safe: true
// }))
// .pipe(rename('style.min.css'))
// .pipe(gulp.dest('./develop/css'))
// // .pipe(browserSync.stream())
// .pipe(notify({
// message: 'Styles are built.'
// }))
// });
//
// gulp.task('sass:lint', ['css:minify'], function() {
// gulp.src([
// 'develop/scss/style.scss'
// ])
// .pipe(sassLint())
// .pipe(sassLint.format())
// .pipe(sassLint.failOnError())
// });
/********************
* Production Tasks
*******************/
gulp.task('compress', function() {
gulp.src(['js/customizer-controls.js',
'js/customizer-scripts.js',
'js/global.js',
'js/home.js',
'js/responsive-menus.js'
])
.pipe(jsMinify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('js'))
})
gulp.task('zip', ['pot'], () =>
gulp.src(['config/**/*',
'js/**/*',
'languages/*',
'lib/**/*',
'page-templates/**/*',
'*.php',
'CHANGELOG.md',
'LICENSE.md',
'README.txt',
'screenshot.png',
'*.css'
], {
base: '.'
})
.pipe(zip('hello-pro-3.zip'))
.pipe(gulp.dest('distribution'))
);
gulp.task('pot', ['postcss'], function() {
return gulp.src(['./**/*.php'])
.pipe(wpPot({
domain: 'hello-pro',
package: 'Hello Pro'
}))
.pipe(gulp.dest('languages/hello-pro-3.pot'));
});
/********************
* All Tasks Listeners
*******************/
gulp.task('watch', function() {
gulp.watch('./src/**/*.css', ['styles']);
});
/**
* Individual tasks.
*/
// gulp.task('scripts', [''])
gulp.task('styles', ['clean', 'postcss']);
gulp.task('build', ['clean-build', 'styles', 'pot', 'zip']);
gulp.task('clean', function() {
return del(['*.css']);
});
gulp.task('clean-build', function() {
return del(['distribution', 'languages']);
});