forked from klpx/webapi-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
32 lines (24 loc) · 889 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
var gulp = require('gulp');
var argv = require('yargs').argv;
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var tsify = require('tsify');
var zip = require('gulp-zip');
var gulpReplace = require('gulp-replace');
function gulpIf(stream, condition, task) {
return condition ? stream.pipe(task) : stream;
}
gulp.task('build', function() {
var dgisApiKey = argv["dgis-key"];
var bundler = browserify({basedir: './src'})
.add('main.ts')
.plugin(tsify);
var stream = bundler.bundle().pipe(source('main.js'));
return gulpIf(stream, dgisApiKey, gulpReplace('2GIS_API_KEY', dgisApiKey))
.pipe(gulp.dest('./build'));
});
gulp.task('pack', function () {
return gulp.src(['build/*', 'static/*', 'manifest.json'], {base: '.'})
.pipe(zip('extension.zip'))
.pipe(gulp.dest('./'));
});