-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (100 loc) · 4.03 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
// -----------------------------------------------------------------------------
// Dependencies
// -----------------------------------------------------------------------------
var gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
sassdoc = require('sassdoc'),
concat = require('gulp-concat');
// -----------------------------------------------------------------------------
// Configuration
// -----------------------------------------------------------------------------
var input = 'client/styles/*.scss',
output = 'client/',
sassOptions = { outputStyle: 'expanded' },
autoprefixerOptions = { browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] },
sassdocOptions = { dest: 'dist/sassdoc' },
bowerPath = './bower_components/',
bowerComponents = [
bowerPath + 'underscore/underscore.js',
bowerPath + 'jquery/dist/jquery.js',
bowerPath + 'angular/angular.js',
bowerPath + 'angular-ui-router/release/angular-ui-router.js',
bowerPath + 'moment/moment.js',
bowerPath + 'bootstrap/dist/js/bootstrap.js',
bowerPath + 'd3/d3.js',
bowerPath + 'd3-tip/index.js',
bowerPath + 'angular-loading-bar/src/loading-bar.js',
bowerPath + 'zeroclipboard/dist/ZeroClipboard.js',
bowerPath + 'angular-sanitize/angular-sanitize.js',
bowerPath + 'showdown/dist/showdown.js',
bowerPath + 'ng-showdown/dist/ng-showdown.js',
bowerPath + 'angular-markdown-directive/markdown.js'
],
angularPath = './client/app/',
angularComponents = [
angularPath + 'content/content.js',
angularPath + 'details/details.js',
angularPath + 'nav/nav.js',
angularPath + 'results/results.js',
angularPath + 'topModules/topModules.js',
angularPath + 'services/*.js'
];
// -----------------------------------------------------------------------------
// Tasks
// -----------------------------------------------------------------------------
gulp.task('sass', function () {
return gulp
.src(input)
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
gulp.task('sassdoc', function () {
return gulp
.src(input)
.pipe(sassdoc(sassdocOptions))
.resume();
});
gulp.task('concatenate', function() {
return gulp.src(bowerComponents)
.pipe(concat('scripts.js'))
.pipe(gulp.dest('./client/'));
});
gulp.task('angularConcatenate', function() {
return gulp.src(angularComponents)
.pipe(concat('angularComponents.js'))
.pipe(gulp.dest('./client/'));
});
// -----------------------------------------------------------------------------
// Watchers
// -----------------------------------------------------------------------------
gulp.task('watch', function() {
return gulp
// Watch the input folder for change,
// and run `sass` task when something happens
.watch(input, ['sass'])
// When there is a change,
// log a message in the console
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
// -----------------------------------------------------------------------------
// Production build
// -----------------------------------------------------------------------------
gulp.task('prod', ['sassdoc', 'concatenate', 'angularConcatenate'], function () {
return gulp
.src(input)
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
// -----------------------------------------------------------------------------
// Default task
// -----------------------------------------------------------------------------
gulp.task('default', ['sass', 'watch' /*, possible other tasks... */]);