-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
128 lines (119 loc) · 3.18 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
var gulp = require('gulp'),
del = require('del'),
rename = require('gulp-rename'),
sort = require('gulp-sort'),
uglify = require('gulp-uglify'),
cssnano = require('gulp-cssnano'),
wpPot = require('gulp-wp-pot'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
pump = require('pump'),
sequence = require('run-sequence'),
readme = require('gulp-readme-to-markdown'),
jasmine = require('gulp-jasmine'),
server = require('karma').Server;
// Configs.
var config = {
src: '.',
dist: '.',
jsDir: '/assets/js',
cssDir: '/assets/css'
};
// Run JSHint & Minify Assets.
gulp.task('js', function(cb) {
pump(
[
gulp.src([
config.src + config.jsDir + '/bgseo/boldgrid-seo.js',
config.src + config.jsDir + '/control/*.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-util.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-words.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-wordcount.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-admin.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-tinymce.js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-content-analysis.js',
config.src +
config.jsDir +
'/bgseo/boldgrid-seo-!(util|admin|tinymce|content-analysis|init|words|wordcount).js',
config.src + config.jsDir + '/bgseo/boldgrid-seo-init.js'
]),
//jshint.reporter( 'fail' ),
concat('bgseo.js'),
gulp.dest(config.dist + config.jsDir),
uglify(),
rename({
suffix: '.min'
}),
gulp.dest(config.dist + config.jsDir)
],
cb
);
});
// Minify CSS Assets.
gulp.task('css', function() {
return gulp
.src([
'!' + config.src + config.cssDir + '/**/*.min.css',
config.src + config.cssDir + '/**/*.css'
])
.pipe(gulp.dest(config.dist + config.cssDir))
.pipe(
cssnano({
discardComments: { removeAll: true }
})
)
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(config.dist + config.cssDir));
});
// Setup Translations.
gulp.task('translate', function() {
return gulp
.src(config.src + '/**/*.php')
.pipe(sort())
.pipe(
wpPot({
domain: 'bgseo',
destFile: 'bgseo.pot',
package: 'bgseo',
bugReport: 'https://boldgrid.com',
team: 'The BoldGrid Team <[email protected]>'
})
)
.pipe(gulp.dest(config.dist + '/languages'));
});
//Convert readme.txt to Markdown for Github
gulp.task('readme', function() {
return gulp
.src(config.src + '/readme.txt')
.pipe(readme())
.pipe(gulp.dest(config.dist));
});
// Copy Butterbean dep.
gulp.task('copyButterbean', function() {
return gulp
.src(['!node_modules/butterbean/.git', 'node_modules/butterbean/**/*'])
.pipe(gulp.dest(config.dist + '/includes/lib/butterbean'));
});
// Copy TextStatistics dep.
gulp.task('copyTextStatistics', function() {
return gulp
.src(['node_modules/text-statistics/**/*.{js,md}'])
.pipe(gulp.dest(config.dist + '/assets/js/text-statistics'));
});
// JS Unit testing
gulp.task('jsTest', function(done) {
return new server(
{
configFile: __dirname + '/karma.conf.js',
singleRun: true
},
done
).start();
});
// Build.
gulp.task('default', function(cb) {
sequence(
['jsTest', 'translate', 'js', 'css', 'readme', 'copyButterbean', 'copyTextStatistics'],
cb
);
});