forked from facebookarchive/puewue-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (85 loc) · 2.77 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var gzip = require('gulp-gzip');
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var gulpif = require('gulp-if');
var es = require('event-stream');
var clean = require('gulp-clean');
gulp.task('check', function() {
gulp.src(['lib/javascripts/**', '!lib/javascripts/graph_components/class.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
});
gulp.task('dashboard', function() {
var stream = gulp.src(['lib/javascripts/power_dashboard.js'])
.pipe(browserify({
insertGlobals : true,
debug : false
}))
.pipe(concat('dashboard.js'))
.pipe(gulp.dest('./tmp'))
return stream;
});
gulp.task('sass', function () {
var sassOpts = {includePaths: [require('node-bourbon').includePaths, './lib/stylesheets']};
if(gulp.env.production) sassOpts.outputStyle = 'compressed';
gulp.src(['./bower_components/normalize.css/normalize.css', './lib/stylesheets/application.scss'])
.pipe(sass(sassOpts))
.pipe(concat(gulp.env.production ? 'dashboard.min.css' : 'dashboard.css'))
.pipe(gulp.dest('./build'));
});
gulp.task('images', function() {
return gulp.src(['./lib/stylesheets/sprite.png'])
.pipe(gulp.dest('./build'))
});
gulp.task('scripts', ['dashboard'], function() {
var stream = gulp.src([
'bower_components/underscore/underscore.js',
'bower_components/backbone/backbone.js',
'bower_components/jquery-tiny-pubsub/dist/ba-tiny-pubsub.js',
'bower_components/json2/json2.js',
'bower_components/sylvester/sylvester.src.js',
'bower_components/d3/d3.js',
'bower_components/tweenjs/src/Tween.js',
'bower_components/moment/moment.js',
'bower_components/animation-frame/AnimationFrame.js',
'bower_components/modernizr/modernizr.js',
'lib/javascripts/graph_components/class.js',
'tmp/dashboard.js'
])
.pipe(concat(gulp.env.production ? 'dashboard.min.js' : 'dashboard.js'))
.pipe(gulpif(gulp.env.production, uglify()))
.pipe(gulp.dest('./build'));
return stream;
});
gulp.task('scripts-with-cleanup', ['scripts'], function() {
gulp.src(['./tmp/*.js'])
.pipe(clean({force: true}))
});
gulp.task('default', function() {
gulp.run('check');
gulp.run('sass');
gulp.run('images');
gulp.run('scripts-with-cleanup');
});
gulp.task('watch', function() {
gulp.watch([
'lib/javascripts/**/*.js',
'lib/stylesheets/**/*.scss',
'lib/stylesheets.sprite.png'
], function() {
gulp.run('scripts-with-cleanup');
});
});