-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (75 loc) · 2.27 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
var gulp = require('gulp'),
browserSync = require('browser-sync').create(),
stylus = require('gulp-stylus'),
sourcemaps = require('gulp-sourcemaps'),
prefix = require('gulp-autoprefixer'),
_plumber = require('gulp-plumber'),
fileinclude = require('gulp-file-include'),
cssmin = require('gulp-cssmin'),
filter = require('gulp-filter'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
svgmin = require('gulp-svgmin'),
gutil = require('gulp-util'),
del = require('del');
function plumber() {
return _plumber({
errorHandler: function (err) {
gutil.beep();
console.log(err);
}
});
}
// Static server
gulp.task('watch', ['css'], function() {
browserSync.init({proxy: {target: "http://style.loc"}});
gulp.watch("static-src/css/**/*.styl", ['css']);
gulp.watch("static-src/svg/**/*.svg", ['svg']);
gulp.watch("static-src/html/**/*.html", ['html']);
gulp.watch("wp-content/themes/style/**/*", ['reload']);
});
gulp.task('clean', function (cb) {
del(['./wp-content/themes/style/library/css'], cb);
});
gulp.task('reload', function() {
browserSync.reload();
});
gulp.task('css', function() {
var filterStylus = filter('**/*.styl');
return gulp.src([
'./static-src/vendor/**/*.css',
'./static-src/css/main.styl'
])
.pipe(plumber())
.pipe(filterStylus)
.pipe(stylus({
sourcemap: {
inline: true,
sourceRoot: '.',
basePath: './static-src/css'
}
}))
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(prefix('last 2 version'))
.pipe(concat('main.css'))
.pipe(sourcemaps.write('./', {sourceRoot: '.' }))
.pipe(filterStylus.restore())
.pipe(gulp.dest('./wp-content/themes/style/library/css'))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./wp-content/themes/style/library/css'))
.pipe(browserSync.stream());
});
gulp.task('svg', function() {
return gulp.src('static-src/svg/**/*.svg')
.pipe(svgmin({plugins: [{cleanpIDs: false}, {moveGroupAttrsToElems: false}]}))
.pipe(gulp.dest('./wp-content/themes/style/library/images'))
browserSync.reload();
});
gulp.task('default', function () {
gulp.run("svg");
// gulp.run("html");
gulp.run("css");
});