-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
58 lines (49 loc) · 1.65 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
var gulp = require('gulp-help')(require('gulp'));
var zip = require('gulp-zip');
var gutil = require('gulp-util');
var rimraf = require('rimraf');
var path = require('path');
var extensionPath = path.resolve(__dirname, 'extension');
var browserify = require('browserify');
var through2 = require('through2');
gulp.task('default', ['build']);
gulp.task('build', 'Rebuild the extension files', ['extension-assets', 'extension-browserify']);
gulp.task('extension-browserify', 'Browserify the extension files', ['prepare'], function() {
function browserified(file, enc, next) {
browserify(file.path).bundle(function(err, res){
file.contents = res;
next(null, file);
});
}
return gulp.src([
'./src/index.js'
])
.pipe(through2.obj(browserified))
.pipe(gulp.dest('./dist'));
});
gulp.task('extension-assets', 'Copy the extension source assets into the dist folder', ['prepare', 'chromex-assets'], function() {
return gulp.src([
'./src/*.png',
'./src/*.svg',
'./src/*.json'
])
.pipe(gulp.dest('./dist'));
});
gulp.task('chromex-assets', 'Assets required for the chromex code to work as expected', ['prepare'], function() {
return gulp.src([
'./node_modules/chromex/scripts/*.js'
])
.pipe(gulp.dest('./dist/scripts'));
});
gulp.task('prepare', 'Prepare the build', ['clean'], function() {
});
gulp.task('clean', 'Clean the extension dist directory', function(cb) {
rimraf(path.join(extensionPath, 'dist'), cb);
});
gulp.task('package', 'Package the extension for deployment', ['build'], function() {
return gulp.src([
'./dist/**',
], { base: './dist' })
.pipe(zip('bundle.zip'))
.pipe(gulp.dest('.//'));
});