forked from xgrommx/vizor-create
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
143 lines (116 loc) · 3.7 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
135
136
137
138
139
140
141
142
var
gulp = require('gulp'),
fs = require('fs'),
path = require('path'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat-util'),
slash = require('gulp-slash'),
del = require('del'),
less = require('gulp-less'),
preprocess = require('gulp-preprocess'),
paths = {
less: './less/build.less',
js: {
plugins: './browser/plugins/*.plugin.js',
player:
[
'./browser/scripts/event-emitter.js',
'./browser/scripts/core.js',
'./browser/scripts/util.js',
'./browser/scripts/connection.js',
'./browser/scripts/variables.js',
'./browser/scripts/graph.js',
'./browser/scripts/node.js',
'./browser/scripts/plugin.js',
'./browser/scripts/subGraphPlugin.js',
'./browser/scripts/threeObject3dPlugin.js',
'./browser/scripts/abstractThreeLoaderObjPlugin.js',
'./browser/scripts/abstractThreeMaterialPlugin.js',
'./browser/scripts/abstractThreeMeshPlugin.js',
'./browser/scripts/worldEditor/worldEditor.js',
'./browser/scripts/worldEditor/worldEditorCamera.js',
'./browser/scripts/worldEditor/worldEditorOriginGrid.js',
'./browser/vendor/three/three.js',
'./browser/vendor/three/OBJLoader.js',
'./browser/vendor/three/OBJMTLLoader.js',
'./browser/vendor/three/MTLLoader.js',
'./browser/vendor/three/DDSLoader.js',
'./browser/vendor/three/VREffect.js',
'./browser/vendor/three/VRControls.js',
'./browser/vendor/three/SceneLoader.js',
'./browser/vendor/three/webvr-polyfill.js',
'./browser/vendor/three/webvr-manager.js',
'./browser/scripts/noise.js',
'./browser/vendor/random.min.js',
'./browser/scripts/datatypes/environmentSettings.js',
'./browser/scripts/textureCache.js',
'./browser/scripts/plugin-manager-bundled.js',
'./browser/plugins/*.plugin.js',
'./browser/scripts/player.js',
'./browser/scripts/player-run.js'
]
}
};
function errorHandler(err) {
console.error(err.message, err.lineNumber, err.stack)
this.emit('end')
}
gulp.task('clean:js:plugins', function(cb)
{
del('./browser/plugins/all.plugins.js', cb);
});
gulp.task('clean:js:player', function(cb)
{
del('./browser/scripts/player.min.js', cb);
});
gulp.task('clean:less', function(cb)
{
del('./browser/style/less.css', cb);
});
gulp.task('clean:js', ['clean:js:plugins', 'clean:js:player']);
gulp.task('clean', ['clean:js']);
gulp.task('js:plugins', ['clean:js:plugins'], function()
{
gulp.src(paths.js.plugins)
.pipe(slash())
.pipe(uglify().on('error', errorHandler))
.pipe(concat.header(';\n'))
.pipe(concat('all.plugins.js'))
.pipe(gulp.dest(path.join(__dirname, 'browser', 'plugins')))
.on('error', errorHandler)
});
gulp.task('js:player', ['clean:js:player'], function()
{
gulp.src(paths.js.player)
.pipe(slash())
.pipe(preprocess({context: { FQDN: process.env.FQDN || 'vizor.io' } }))
.pipe(uglify().on('error', errorHandler))
.pipe(concat.header(';\n'))
.pipe(concat('player.min.js'))
.pipe(gulp.dest(path.join(__dirname, 'browser', 'scripts')))
.on('error', errorHandler)
});
gulp.task('js', ['js:plugins', 'js:player']);
gulp.task('less', ['clean:less'], function() {
gulp.src(paths.less)
.pipe(slash())
.pipe(less({
paths: [ path.join(__dirname, 'less') ]
}).on('error', errorHandler))
.pipe(concat('less.css'))
.pipe(gulp.dest(path.join(__dirname, 'browser', 'style')))
.on('error', errorHandler)
});
gulp.task('watch', ['default'], function() {
gulp.watch('less/**/*', ['less']);
gulp.watch(paths.js.plugins, ['js:plugins']);
gulp.watch(paths.js.player, ['js:player']);
});
gulp.task('watch:less', function() {
gulp.watch('less/**/*', ['less']);
});
gulp.task('watch:player', function() {
gulp.watch(paths.js.plugins, ['js:plugins']);
gulp.watch(paths.js.player, ['js:player']);
});
gulp.task('default', ['less', 'js']);