-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
112 lines (105 loc) · 2.61 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
var gulp = require('gulp');
var header = require('gulp-header');
var jbb_profile = require('gulp-jbb-profile');
var webpack = require('webpack-stream');
var PROD = JSON.parse(process.env.PROD_DEV || "0");
//
// Compile test files
//
gulp.task('test/simple-profile', function() {
return gulp
.src([ 'test/simple-profile/specs.yaml' ])
.pipe(jbb_profile())
.pipe(gulp.dest('test/simple-profile'));
});
gulp.task('test/second-profile', function() {
return gulp
.src([ 'test/simple-profile/second.yaml' ])
.pipe(jbb_profile())
.pipe(gulp.dest('test/simple-profile'));
});
//
// Compile the binary loader
//
gulp.task('dist/jbb', function() {
return gulp.src('decoder.js')
.pipe(webpack({
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
],
},
node: {
'fs': 'empty'
},
output: {
// The output filename
filename: PROD ? 'jbb.min.js' : 'jbb.js',
// Export itself to a global var
libraryTarget: 'var',
// Name of the global var: 'JBB.BinaryLoader'
library: [ 'JBB', 'BinaryLoader' ]
},
externals: {
'three': 'THREE',
},
plugins: ([
new webpack.webpack.optimize.DedupePlugin(),
new webpack.webpack.DefinePlugin({
GULP_BUILD : PROD
})
]).concat(PROD ? [
new webpack.webpack.optimize.UglifyJsPlugin({
minimize: true
})
] : [])
}))
.pipe(header("/* JBB Binary Bundle Loader - https://github.com/wavesoft/jbb */\n"))
.pipe(gulp.dest('dist'));
});
//
// Compile the source loader
//
gulp.task('dist/jbb-loader', function() {
return gulp.src('loader.js')
.pipe(webpack({
module: {
loaders: [
{ test: /\.json$/, loader: 'json' },
],
},
node: {
'fs': 'empty'
},
output: {
// The output filename
filename: PROD ? 'jbb-loader.min.js' : 'jbb-loader.js',
// Export itself to a global var
libraryTarget: 'var',
// Name of the global var: 'Foo'
library: [ 'JBB', 'SourceLoader' ]
},
externals: {
'three': 'THREE',
},
plugins: ([
new webpack.webpack.optimize.DedupePlugin(),
new webpack.webpack.DefinePlugin({
GULP_BUILD : PROD
})
]).concat(PROD ? [
new webpack.webpack.optimize.UglifyJsPlugin({
minimize: true
})
] : [])
}))
.pipe(header("/* JBB Source Bundle Loader - https://github.com/wavesoft/jbb */\n"))
.pipe(gulp.dest('dist'));
});
// The files to pack on dist release
gulp.task('dist', [
'dist/jbb',
'dist/jbb-loader'
]);
// By default run only script
gulp.task('default', ['dist']);