-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (89 loc) · 2.63 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
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename');
var argv = require('yargs').argv;
var git = require('gulp-git');
var runSequence = require('run-sequence');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin'),
cache = require('gulp-cache');
var minifycss = require('gulp-minify-css');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var sourcemaps = require('gulp-sourcemaps');
var theme = "themes/brennanhampton/"
var content = "content-brennanhampton/"
gulp.task('browser-sync', function() {
browserSync({
proxy: {
target: "http://core",
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('images', function(){
gulp.src(theme + 'images/**/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest(theme + 'images/build/'));
});
gulp.task('styles', function(){
gulp.src([theme + 'scss/**/*.scss'])
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer('last 2 versions'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(theme))
// .pipe(rename({suffix: '.min'}))
// .pipe(minifycss())
// .pipe(gulp.dest('/'))
runSequence('bs-reload', 'gitadd', 'gitcommit');
});
gulp.task('scripts', function(){
return gulp.src(theme + 'scripts/**/*.js')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(concat('main.js'))
.pipe(gulp.dest(theme + 'scripts/build/'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(theme + 'scripts/build/'))
runSequence('bs-reload', 'gitadd', 'gitcommit');
});
gulp.task('gitadd', function(){
console.log('adding');
return gulp.src('.')
.pipe(git.add());
});
gulp.task('gitcommit', function(){
console.log('commiting');
return gulp.src('')
.pipe(git.commit('initial commit'));
});
/*
gulp.task('gitpush', function(){
console.log('pushing...');
git.push('origin', 'master', function (err) {
if (err) throw err;
});
});
*/
gulp.task('gitsend', function() {
runSequence('gitadd', 'gitcommit');
});
gulp.task('default', ['browser-sync', 'styles', 'gitsend'], function(){
gulp.watch(theme + "scss/**/*.scss", ['styles']);
// gulp.watch(theme + "scripts/**/*.js", ['scripts']);
gulp.watch(content + "**/*.md", ['bs-reload']);
});