This repository has been archived by the owner on Dec 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
94 lines (84 loc) · 2.09 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
// Require all the things (that we need)
var autoprefixer = require('gulp-autoprefixer');
var gulp = require('gulp');
var minify = require('gulp-minify');
var phpcs = require('gulp-phpcs');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var sort = require('gulp-sort');
var watch = require('gulp-watch');
var wp_pot = require('gulp-wp-pot');
// Define the source paths for each file type
var src = {
scss: ['assets/scss/**/*'],
js: ['assets/js/**/*.js','!assets/js/*.min.js'],
php: ['**/*.php','!vendor/**','!node_modules/**']
};
// Define the destination paths for each file type
var dest = {
scss: 'assets/css',
js: 'assets/js'
};
// Compile the SASS
gulp.task( 'sass', function() {
gulp.src(src.scss)
.pipe(sass({
outputStyle: 'compressed'
})
.on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(dest.scss));
});
// Minify the JS
gulp.task( 'js', function() {
gulp.src(src.js)
.pipe(minify({
mangle: false,
ext:{
min:'.min.js'
}
}))
.pipe(gulp.dest(dest.js))
});
// Check our PHP
gulp.task( 'php', function() {
gulp.src(src.php)
.pipe(phpcs({
bin: 'vendor/bin/phpcs',
standard: 'WordPress-Core'
}))
.pipe(phpcs.reporter('log'));
});
// Create the .pot translation file
gulp.task( 'translate', function() {
gulp.src(src.php)
.pipe(sort())
.pipe(wp_pot({
domain: 'cpt-onomies',
destFile:'cpt-onomies.pot',
package: 'cpt-onomies',
bugReport: 'https://github.com/bamadesigner/cpt-onomies/issues',
lastTranslator: 'Rachel Carden <[email protected]>',
team: 'Rachel Carden <[email protected]>',
headers: false
}))
.pipe(gulp.dest('languages'));
});
// Watch the files
gulp.task( 'watch', function() {
gulp.watch(src.scss,['sass']);
gulp.watch(src.js,['js']);
gulp.watch(src.php,['translate','php']);
});
// Test things out
gulp.task( 'test', ['php'] );
// Compile our assets
gulp.task( 'compile', ['sass','js'] );
// Let's get this party started
gulp.task( 'default', ['compile','translate','test'] );