Skip to content

Commit 8ec3638

Browse files
committed
Improve gulp tasks
1 parent 20e0c3e commit 8ec3638

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

gulpfile.js

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var fs = require('fs');
55
var gulp = require('gulp');
66

77
// Gulp plugins
8-
var gutil = require('gulp-util');
8+
var gutil = require('gulp-util');
99
var concat = require('gulp-concat');
1010
var header = require('gulp-header');
1111
var autoprefixer = require('gulp-autoprefixer');
@@ -14,53 +14,57 @@ var minify = require('gulp-minify-css');
1414
var rename = require('gulp-rename');
1515

1616
// Misc/global vars
17-
var pkg = JSON.parse(fs.readFileSync('package.json'));
18-
var banner = [
19-
'@charset "UTF-8";\n',
20-
'/*!',
21-
' * <%= name %> -<%= homepage %>',
22-
' * Version - <%= version %>',
23-
' * Licensed under the MIT license - http://opensource.org/licenses/MIT',
24-
' *',
25-
' * Copyright (c) <%= new Date().getFullYear() %> <%= author.name %>',
26-
' */\n\n'
27-
].join('\n');
17+
var pkg = JSON.parse(fs.readFileSync('package.json'));
2818
var activatedAnimations = activateAnimations();
2919

20+
// Task options
21+
var opts = {
22+
destPath: './',
23+
concatName: 'animate.css',
24+
25+
autoprefixer: {
26+
browsers: ['last 2 versions'],
27+
cascade: false
28+
},
29+
30+
minRename: {
31+
suffix: '.min'
32+
},
33+
34+
banner: [
35+
'@charset "UTF-8";\n',
36+
'/*!',
37+
' * <%= name %> -<%= homepage %>',
38+
' * Version - <%= version %>',
39+
' * Licensed under the MIT license - http://opensource.org/licenses/MIT',
40+
' *',
41+
' * Copyright (c) <%= new Date().getFullYear() %> <%= author.name %>',
42+
' */\n\n'
43+
].join('\n')
44+
};
45+
3046
// ----------------------------
3147
// Gulp task definitions
3248
// ----------------------------
3349

3450
gulp.task('default', function() {
35-
runSequence('concatCSS', 'prefixes', 'minifyCSS', 'addHeader');
51+
runSequence('createCSS', 'addHeader');
3652
});
3753

38-
gulp.task('concatCSS', function() {
54+
gulp.task('createCSS', function() {
3955
return gulp.src(activatedAnimations)
40-
.pipe(concat('animate.css'))
41-
.pipe(gulp.dest('./'));
42-
});
43-
44-
gulp.task('prefixes', function() {
45-
return gulp.src('animate.css')
46-
.pipe(autoprefixer({
47-
browsers: ['last 2 versions'],
48-
cascade: false
49-
}))
50-
.pipe(gulp.dest('./'));
51-
});
52-
53-
gulp.task('minifyCSS', function() {
54-
return gulp.src('animate.css')
55-
.pipe(rename('animate.min.css'))
56+
.pipe(concat(opts.concatName))
57+
.pipe(autoprefixer(opts.autoprefixer))
58+
.pipe(gulp.dest(opts.destPath))
59+
.pipe(rename(opts.minRename))
5660
.pipe(minify())
57-
.pipe(gulp.dest('./'));
61+
.pipe(gulp.dest(opts.destPath));
5862
});
5963

6064
gulp.task('addHeader', function() {
6165
return gulp.src('*.css')
62-
.pipe(header(banner, pkg))
63-
.pipe(gulp.dest('./'));
66+
.pipe(header(opts.banner, pkg))
67+
.pipe(gulp.dest(opts.destPath));
6468
});
6569

6670
// ----------------------------

0 commit comments

Comments
 (0)