This repository has been archived by the owner on Aug 16, 2018. It is now read-only.
forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
126 lines (111 loc) · 2.89 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
'use strict';
const fs = require('fs');
const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const gutil = require('gulp-util');
const header = require('gulp-header');
const browserSync = require('browser-sync');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const pkg = require('./package.json');
const jsprettify = require('gulp-jsbeautifier');
const babel = require('gulp-babel');
const stripComments = require('gulp-strip-comments');
/// Build the scripts
gulp.task('build', function() {
browserify('./src/index.js')
.bundle()
.pipe(source('gpu.js'))
.pipe(buffer())
.pipe(stripComments())
.pipe(babel())
.pipe(header(fs.readFileSync('./src/wrapper/header.js', 'utf8'), { pkg : pkg }))
.pipe(gulp.dest('bin'));
browserify('./src/index-core.js')
.bundle()
.pipe(source('gpu-core.js'))
.pipe(buffer())
.pipe(stripComments())
.pipe(babel())
.pipe(header(fs.readFileSync('./src/wrapper/header.js', 'utf8'), { pkg : pkg }))
.pipe(gulp.dest('bin'));
});
/// Minify the build script, after building it
gulp.task('minify', ['build'], function() {
return (
gulp.src('bin/gpu.js')
.pipe(rename('gpu.min.js'))
.pipe(
uglify({preserveComments: 'license'})
.on('error', gutil.log)
)
.pipe(gulp.dest('bin'))
) && (
gulp.src('bin/gpu-core.js')
.pipe(rename('gpu-core.min.js'))
.pipe(
uglify({preserveComments: 'license'})
.on('error', gutil.log)
)
.pipe(gulp.dest('bin'))
);
});
/// The browser sync prototyping
gulp.task('bsync', function(){
// Syncs browser
browserSync.init({
server: {
baseDir: './'
},
open: true,
startPath: "/test/html/test-all.html",
// Makes it easier to test on external mobile devices
host: "0.0.0.0",
tunnel: true
});
// Detect change -> rebuild TS
gulp.watch(['src/**.js'], ['minify']);
});
/// Auto rebuild and host
gulp.task('default', ['minify','bsync']);
/// Beautify source code
/// Use before merge request
/// Excludes the parser.js that was jison generated
gulp.task('beautify', function() {
gulp.src(['src/**/*.js', '!src/parser.js'])
.pipe(jsprettify({
indent_size: 3,
indent_char: ' ',
indent_with_tabs: true
}))
.pipe(gulp.dest('src'));
});
gulp.task('injectCSS', function(){
let signatureColor = '#ff75cf';
let linkColor = '#4c7fbd';
let themeColor = '#186384';
// !important is used because the original rule is using it.
let cssRules = `
.signature, a {
color: ${signatureColor};
}
h4.name {
background: ${themeColor};
}
nav > ul > li > a, nav a:hover, nav > h2 > a {
color: ${linkColor} !important;
}
span.param-type, .params td .param-type {
color: ${themeColor};
}
`;
fs.appendFile('./doc/styles/jsdoc.css', cssRules, (err)=>{
if(err){
throw new Error(err);
}
console.log('CSS Injected');
});
});