forked from ag-grid/ag-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (63 loc) · 2 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
var gulp = require('gulp');
var path = require('path');
var uglify = require('gulp-uglify');
var foreach = require('gulp-foreach');
var rename = require("gulp-rename");
var stylus = require('gulp-stylus');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var streamify = require("streamify");
var nib = require('nib');
gulp.task('default', ['build', 'watch']);
// Build
gulp.task('build', ['stylus', 'js']);
gulp.task('stylus', stylusTask);
gulp.task('js', jsTask);
// Watch
gulp.task('watch', watchTask);
function jsTask() {
return browserify('./src/js/main.js', {debug: true})
.bundle()
.pipe(source('angularGrid.js'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/dist'))
.pipe(buffer())
.pipe(uglify())
.pipe(rename('angularGrid.min.js'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/dist'));
}
function stylusTask() {
// Uncompressed
gulp.src('./src/styles/*.styl')
.pipe(foreach(function(stream, file) {
return stream
.pipe(stylus({
use: nib(),
compress: false,
}))
.pipe(gulp.dest('./docs/dist/'))
.pipe(gulp.dest('./dist/'));
}));
// Compressed
return gulp.src('./src/styles/*.styl')
.pipe(foreach(function(stream, file) {
return stream
.pipe(stylus({
use: nib(),
compress: true
}))
.pipe(rename((function() {
var name = path.basename(file.path);
var dot = name.indexOf('.');
name = name.substring(0, dot) + '.min.css';
return name;
})()))
.pipe(gulp.dest('./dist/'))
.pipe(gulp.dest('./docs/dist/'));
}));
}
function watchTask() {
gulp.watch('./src/**/*', ['build']);
}