-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
executable file
·38 lines (36 loc) · 971 Bytes
/
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
var
fs = require('fs'),
gulp = require('gulp'),
del = require('del'),
merge = require('merge-stream'),
webpackStream = require('webpack-stream'),
replace = require('gulp-replace');
function versionAndPack(filename, webpackPlugins) {
return gulp.src('./src/index.js')
.pipe(webpackStream({
output: {
filename: filename
},
plugins: webpackPlugins,
devtool: 'source-map'
}))
.pipe(replace('AFRAME_ALTSPACE_VERSION', version))
.pipe(gulp.dest('./dist/'));
}
gulp.task('clean:dist', function () {
return del(['./dist/*.js']);
});
gulp.task('dist', ['clean:dist'], function () {
version = JSON.parse(fs.readFileSync('./package.json')).version;
console.log('version', version);
return merge(
versionAndPack('aframe-altspace-component.js'),
versionAndPack(
'aframe-altspace-component.min.js',
[
new webpackStream.webpack.optimize.UglifyJsPlugin(),
new webpackStream.webpack.optimize.OccurrenceOrderPlugin()
]
)
);
});