-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
167 lines (123 loc) · 3.2 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
/**
* Gulp tasks for automating our compile and build process.
*
* @package Digital Nomad Theme
* @author brandiD
* @link http://thebrandid.com
* @license GPL-2.0+
* @version 1.0
*/
'use strict';
var gulp = require('gulp'),
// Sass/CSS processes
bourbon = require('bourbon').includePaths,
neat = require('bourbon-neat').includePaths,
concat = require('gulp-concat'),
sass = require('gulp-sass'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
cssMinify = require('gulp-cssnano'),
sassLint = require('gulp-sass-lint'),
del = require('del'),
postcssSVG = require('postcss-svg'),
jsMinify = require('gulp-uglify'),
// Utilities
rename = require('gulp-rename'),
pxtorem = require('postcss-pxtorem'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
cssMQpacker = require('css-mqpacker'),
browserSync = require('browser-sync'),
zip = require('gulp-zip'),
wpPot = require('gulp-wp-pot'),
reload = browserSync.reload;
/*************
* 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', function() {
return gulp.src('develop/scss/*.scss')
// Error handling
.pipe(plumber({
errorHandler: handleErrors
}))
// Wrap tasks in a sourcemap
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: [].concat(bourbon, neat),
errLogToConsole: true,
outputStyle: 'expanded' // Options: nested, expanded, compact, compressed
}))
.pipe(postcss([
autoprefixer({
browsers: ['last 2 versions']
}),
pxtorem({
replace: false,
propList: ['font-size'],
mediaQuery: false,
rootValue: 10
}),
cssMQpacker({
sort: true
}),
postcssSVG({
paths: ['images']
})
]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./'))
.pipe(browserSync.stream())
.pipe(notify({
message: 'PostCSS is done.'
}));
});
gulp.task('sass:lint', ['postcss'], function() {
gulp.src([
'develop/scss/*.scss'
])
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
/********************
* All Tasks Listeners
*******************/
gulp.task('watch', function() {
browserSync({
open: false, //no new tab
proxy: "https://digital-nomad.local" // use http://_s.com:3000 to use BrowserSync
});
gulp.watch('develop/scss/**/*.scss', ['styles']);
});
/**
* Individual tasks.
*/
// gulp.task('scripts', [''])
gulp.task('styles', ['clean', 'sass:lint']);
// gulp.task('build', ['styles', 'compress', 'zip']);
gulp.task('clean', function() {
del(['*.css*']);
});