forked from yhat/rodeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (98 loc) · 2.99 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
const _ = require('lodash'),
gulp = require('gulp'),
concat = require('gulp-concat'),
less = require('gulp-less'),
path = require('path'),
sourcemaps = require('gulp-sourcemaps'),
map = require('vinyl-map'),
uglify = require('gulp-uglify'),
tmpAppDirectory = 'app',
outputMap = {
app: tmpAppDirectory,
fonts: path.join(tmpAppDirectory, 'fonts'),
themes: path.join(tmpAppDirectory, 'themes')
};
gulp.task('ace:core', function () {
return gulp.src([
'src/ace/ace.js',
'src/ace/**/*.js',
'!src/ace/mode-*.js',
'!src/ace/theme-*.js'
]).pipe(sourcemaps.init())
.pipe(concat('ace.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputMap.app));
});
gulp.task('ace:modes-js', function () {
return gulp.src([
'src/ace/mode-*.js'
]).pipe(gulp.dest(outputMap.app));
});
gulp.task('ace:themes-js', function () {
return gulp.src([
'src/ace/theme-*.js'
]).pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputMap.app));
});
/**
* Ace is so large that its easier to keep it separate.
* Also, it minifies well, unlike other ext
*/
gulp.task('ace', ['ace:core', 'ace:themes-js', 'ace:modes-js']);
/**
* This files should be included in every screen, and have already been processed, so keep it separate.
*/
gulp.task('external', function () {
return gulp.src([
'node_modules/jquery/dist/jquery.min.js',
'src/browser/lib/*.js'
]).pipe(sourcemaps.init())
.pipe(concat('external.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputMap.app));
});
gulp.task('html', function () {
return gulp.src([
'src/browser/entry/*.html'
]).pipe(gulp.dest(outputMap.app));
});
/**
* I don't know why less doesn't do this automatically.
*/
gulp.task('fonts', function () {
return gulp.src([
'node_modules/font-awesome/fonts/**/*',
'src/fonts/lato/Lato-Regular.ttf',
'src/fonts/NotoMono-hinted/NotoMono-Regular.ttf',
'src/fonts/NotoSans-unhinted/NotoSans-Regular.ttf',
'src/fonts/NotoSerif-unhinted/NotoSerif-Regular.ttf',
'src/fonts/roboto/Roboto-Regular.ttf',
'src/fonts/fonts.css'
]).pipe(gulp.dest(outputMap.fonts));
});
gulp.task('themes', ['fonts'], function () {
return gulp.src([
'src/themes/*.less'
]).pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(outputMap.themes));
});
/**
* Make an "app" version of the package.json according to electron-builder's arbitrary rules and put it in the
* temp directory to be consumed by them.
*/
gulp.task('package.json', function () {
return gulp.src('package.json')
.pipe(map(function (chunk) {
const pkg = JSON.parse(chunk.toString());
pkg.main = 'index.js';
return JSON.stringify(_.omit(pkg, ['devDependencies', 'build', 'bin', 'scripts', 'jest']), null, 2);
}))
.pipe(gulp.dest(outputMap.app));
});
gulp.task('build', ['themes', 'external', 'ace', 'html', 'package.json']);
gulp.task('default', ['build']);