-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (73 loc) · 2.06 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
var gulp = require('gulp'),
compass = require('gulp-compass'),
coffee = require('gulp-coffee'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
autoprefixer = require('gulp-autoprefixer'),
cleanCSS = require('gulp-clean-css'),
theme = 'wp-content/themes/nome_do_tema/';
// Error
function onError(err) {
console.log(err);
this.emit('end');
}
// Buld
gulp.task('build', ['compass', 'coffee', 'scripts', 'styles', 'watch']);
// Default
gulp.task('default', ['build', 'watch']);
// Coffee
gulp.task('coffee', function() {
gulp.src(theme + 'assets/coffee/**/*.coffee')
.pipe(coffee({bare: true}))
.on('error', onError)
.pipe(gulp.dest(theme + 'assets/js'));
});
// Compass
gulp.task('compass', function() {
gulp.src(theme + 'assets/sass/**/*.scss')
.pipe(compass({
config_file: 'config.rb',
css: theme + 'assets/css',
font: theme + 'assets/fonts',
sass: theme + 'assets/sass',
image: theme + 'assets/images'
}))
.on('error', onError)
})
// Scripts
gulp.task('scripts', function() {
return gulp.src([
// theme + 'assets/bower_components/jquery/dist/jquery.min.js',
])
.pipe(concat('app.js', {
outSourceMap: true
}))
.pipe(uglify())
.on('error', onError)
.pipe(gulp.dest(theme + 'assets/js'));
});
// Styles
gulp.task('styles', function() {
return gulp.src([
theme + 'assets/css/app.css'
])
.pipe(cleanCSS({
compatibility: 'ie8',
keepSpecialComments: 0})
)
.on('error', onError)
.pipe(concat('styles.css'))
.pipe(autoprefixer({
browsers: ['last 10 versions'],
cascade: false
}))
.pipe(gulp.dest(theme + 'assets/css'));
});
// Watch
gulp.task('watch', function() {
gulp.watch(theme + 'assets/sass/**/*.scss', ['compass'])
gulp.watch(theme + 'assets/coffee/**/*.coffee', ['coffee'])
gulp.watch([theme + 'assets/css/**/*.css', '!' + theme + 'assets/css/styles.css'], ['styles'])
gulp.watch([theme + 'assets/js/**/*.js', '!' + theme + 'assets/js/app.js'], ['scripts'])
});