-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
134 lines (117 loc) · 3.13 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var gulp = require('gulp');
// Plugins.
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var yaml = require('js-yaml');
var fs = require('fs');
var header = require('gulp-header');
var adminBuildDir = 'Resources/public/assets/build';
var templatesPath = 'Resources/public/templates/';
// Get information for top of minified files.
var pkg = require('./version.json');
var banner = [
'/**',
' * @name <%= pkg.name %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.link %>',
' */',
''
].join('\n');
// @TODO: Discover this structure automatically
var templates = {
'horizon': {
'slides': [
'horizon-image-text',
'horizon-image-text-2x',
'horizon-calendar-info',
'horizon-calendar-list',
'horizon-calendar-single'
]
}
};
/**
* Process SCSS using libsass
*/
gulp.task('sass', function (done) {
'use strict';
// Iterates through the screen and slide templates defined in templates variable, and compresses each one.
for (var folder in templates) {
for (var templateType in templates[folder]) {
var arr = templates[folder][templateType];
arr.forEach(function (element) {
var path = templatesPath + folder + '/' + templateType + '/' + element + '/';
gulp.src(path + element + '.scss')
.pipe(sass({
outputStyle: 'compressed',
includePaths: [
'Resources/sass/compass-mixins/lib'
]
}).on('error', sass.logError))
.pipe(gulp.dest(path));
});
}
}
done();
});
// We only want to process our own non-processed JavaScript files.
var adminJsPath = (function () {
var configFiles = [
'Resources/config/angular.yml'
],
jsFiles = [],
// Breadth-first descend into data to find "files".
buildFiles = function (data) {
if (typeof(data) === 'object') {
for (var p in data) {
if (p === 'files') {
jsFiles = jsFiles.concat(data[p]);
}
else {
buildFiles(data[p]);
}
}
}
};
configFiles.forEach(function (path) {
var data = yaml.safeLoad(fs.readFileSync(path, 'utf8'));
buildFiles(data);
});
return jsFiles.map(function (file) {
return 'Resources/public/' + file.split('bundles/os2displayhorizontemplate/')[1];
});
}());
/**
* Run Javascript through JSHint.
*/
gulp.task('jshint', function () {
return gulp.src(adminJsPath)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
/**
* Build single app.js file.
*/
gulp.task('js', function () {
return gulp.src(adminJsPath)
.pipe(concat('os2displayhorizontemplate.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(rename({extname: ".min.js"}))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest(adminBuildDir));
}
);
/**
* Build single app.js file.
*/
gulp.task('js-src', function (done) {
adminJsPath.forEach(function (path) {
process.stdout.write(path + '\n');
});
done();
});