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
|
'use strict';
require('coffee-script/register'); // For coffee-script mocha unit tests
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var mocha = require('gulp-mocha');
var order = require('gulp-order');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var del = require('del');
var exec = require('child_process').exec;
/**
* Common directories used by tasks below.
* @type {object}
*/
var path = {
source: {
coffee: 'src/',
sass: 'sass/'
},
dist: {
js: 'dist/js/',
css: 'dist/css/'
},
test: {
unit: 'tests/unit/'
},
doc: 'doc/'
};
/**
* The default task simply calls the master 'build' task.
*/
gulp.task('default', ['build']);
/**
* Builds the distribution files by packaging the compiled javascript source
* into the `dist/js/` directory and building the css into the `dist/css`
* directory
*/
gulp.task('build', ['sass', 'sass-minify'], function () {
gulp.src(path.source.coffee + '**/*.coffee')
.pipe(coffee({bare: true}).on('error', gutil.log))
.pipe(order([
'epoch.js',
'core/context.js',
'core/util.js',
'core/d3.js',
'core/format.js',
'core/chart.js',
'core/css.js',
'data.js',
'model.js',
'basic.js',
'basic/*.js',
'time.js',
'time/*.js',
'adapters.js',
'adapters/*.js'
]))
.pipe(concat('epoch.js'))
.pipe(gulp.dest(path.dist.js))
.pipe(uglify().on('error', gutil.log))
.pipe(rename('epoch.min.js'))
.pipe(gulp.dest(path.dist.js));
});
/**
* Generates epoch CSS from Sass source.
*/
gulp.task('sass', function () {
gulp.src(path.source.sass + 'epoch.scss')
.pipe(sass({ outputStyle: 'compact' }))
.pipe(rename('epoch.css'))
.pipe(gulp.dest(path.dist.css));
});
/**
* Generates the minified version of the epoch css from sass source.
*/
gulp.task('sass-minify', function () {
gulp.src(path.source.sass + 'epoch.scss')
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(rename('epoch.min.css'))
.pipe(gulp.dest(path.dist.css));
});
/**
* Watch script for recompiling JavaScript and CSS
*/
gulp.task('watch', function () {
gulp.watch(path.source.coffee + '**/*.coffee', ['build']);
gulp.watch(path.source.sass + '**/*.scss', ['sass', 'sass-minify']);
});
/**
* Cleans all build and distribution files.
*/
gulp.task('clean', function (cb) {
del([ path.dist.js, path.dist.css]).then(function () {
cb();
});
});
|