forked from blivesta/crosscover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (66 loc) · 1.72 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
var del = require('del');
var gulp = require('gulp');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var pkg = require('./package.json');
var plumber = require('gulp-plumber');
var cssnext = require('gulp-cssnext');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var banner = [
'/*!',
' * <%= pkg.name %> v<%= pkg.version %>',
' * <%= pkg.description %>',
' * <%= pkg.homepage %>',
' * License : <%= pkg.license %>',
' * Author : <%= pkg.author %>',
' */',
''].join('\n');
var browsers = ['last 2 versions'];
var dirs = {
src:'./src',
dist:'./dist'
};
gulp.task('css', function () {
return gulp.src(dirs.src + '/css/' + pkg.name + '.css')
.pipe(header(banner, {pkg:pkg}))
.pipe(cssnext({
browsers: browsers,
}))
.pipe(gulp.dest(dirs.dist + '/css'))
.pipe(cssnext({
browsers: browsers,
compress: true
}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(dirs.dist + '/css'));
});
gulp.task('js', function(){
return gulp.src(dirs.src + '/js/' + pkg.name + '.js')
.pipe(plumber())
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(header(banner, { pkg:pkg }))
.pipe(gulp.dest(dirs.dist + '/js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(header(banner, { pkg:pkg }))
.pipe(gulp.dest(dirs.dist + '/js'));
});
gulp.task('cleanup', function(){
return del([ './dist' ]);
});
gulp.task('default',['build'], function(){
gulp.watch(['./src/css/**/*.css'], ['css']);
gulp.watch(['./src/js/*.js'], ['js']);
});
gulp.task('build', function(cd){
runSequence(
'cleanup',
['js'],
'css',
cd
);
});