forked from vpython/glowscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·76 lines (71 loc) · 2.23 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
var gulp = require('gulp')
, uglify = require('gulp-uglify-es').default
, concat = require('gulp-concat-util')
, wrap = require('gulp-wrap')
, tap = require('gulp-tap')
, header = require('gulp-header')
, util = require('gulp-util')
, path = require('path')
, version
, glowscript_libraries;
version = '3.2.2';
glowscript_libraries = {
"glow": [
"lib/jquery/2.1/jquery.mousewheel.js",
"lib/flot/jquery.flot.js",
"lib/flot/jquery.flot.crosshair_GS.js",
"lib/plotly.js",
"lib/opentype/poly2tri.js",
"lib/opentype/opentype.js",
"lib/glMatrix.js",
"lib/webgl-utils.js",
"lib/glow/property.js",
"lib/glow/vectors.js",
"lib/glow/mesh.js",
"lib/glow/canvas.js",
"lib/glow/orbital_camera.js",
"lib/glow/autoscale.js",
"lib/glow/WebGLRenderer.js",
"lib/glow/graph.js",
"lib/glow/color.js",
"lib/glow/shapespaths.js",
"lib/glow/primitives.js",
"lib/glow/api_misc.js",
"lib/glow/extrude.js",
"lib/glow/shaders.gen.js"
],
"compiler": [
"lib/compiling/GScompiler.js",
"lib/compiling/acorn.js",
"lib/compiling/papercomp.js"
],
RSrun: [
"lib/rapydscript/runtime.js"
],
RScompiler: [
"lib/rapydscript/compiler.js",
"lib/compiling/GScompiler.js",
"lib/compiling/acorn.js",
"lib/compiling/papercomp.js"
],
};
gulp.task('default', async function() {
var shaders = []
, shader_key;
gulp.src('./shaders/*.shader')
.pipe(tap(function(file) {
shader_key = path.basename(file.path, '.shader');
file.contents = Buffer.from('"' + shader_key + '":' + JSON.stringify(file.contents.toString()));
return file;
}))
.pipe(concat('shaders.gen.js', { sep : ',\n' }))
.pipe(wrap('Export({ shaders: {\n<%= contents %>\n}});'))
.pipe(gulp.dest('./lib/glow/'));
Object.keys(glowscript_libraries).forEach(function(lib) {
return gulp.src(glowscript_libraries[lib])
.pipe(uglify().on('error', util.log)) // notice the error event here
.pipe(concat(lib + '.' + version + '.min.js'))
.pipe(header("/*This is a combined, compressed file. Look at https://github.com/BruceSherwood/glowscript for source code and copyright information.*/"))
.pipe(gulp.dest('./package/'));
});
});