-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
63 lines (55 loc) · 1.76 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
var gulp = require('gulp');
var del = require('del');
gulp.task('clean:min-css', function() {
// Delete all *.min.css files in the css/ directory so we don't get duplicates
return del([
'css/*.min.css'
]);
});
gulp.task('clean:min-js', function() {
// Delete previously compiled global.min.js files in the js/ directory so we don't get duplicates
return del([
'js/global.min.js'
]);
});
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var wpIncludesDir = '../../../wp-includes/js';
gulp.task('js', ['clean:min-js'], function() {
return gulp.src([
// wpIncludesDir + '/jquery/jquery.js',
wpIncludesDir + '/jquery/jquery-migrate.js',
wpIncludesDir + '/wp-embed.js',
wpIncludesDir + '/wp-emoji-release.min.js',
wpIncludesDir + '/mediaelement/mediaelement-and-player.min.js',
wpIncludesDir + '/mediaelement/wp-mediaelement.js',
'js/menu.js',
'js/analytics.js'
])
.pipe( concat('global.min.js') )
.pipe( uglify() )
.pipe( gulp.dest('js/') );
});
var foreach = require('gulp-foreach');
var path = require('path');
var concatCSS = require('gulp-concat-css');
var autoprefixer = require('gulp-autoprefixer');
var cssnano = require('gulp-cssnano');
gulp.task('css', ['clean:min-css'], function() {
gulp.src('css/*.css')
.pipe(
// Loop over each stream, figure out the filename, and run the stream through concatCSS() passing along the dynamic filename
foreach(function(stream, file) {
// Get the filename without the extension...
var filename = path.basename(file.path, '.css');
return stream.pipe( concatCSS(filename + '.min.css') )
})
)
// Autoprefix
.pipe( autoprefixer() )
// minify CSS
.pipe( cssnano() )
// Save out the new file
.pipe( gulp.dest('css/') );
});
gulp.task('default', ['css', 'js'] );