-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
56 lines (45 loc) · 1.87 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
/* jshint ignore:start */
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var preprocess = require('gulp-preprocess');
var crx = require('gulp-crx-pack');
var manifest = require('./src/manifest');
var fs = require('fs');
var jshint = require('gulp-jshint');
gulp.task('lint', function () {
return gulp.src(['./src/**/*.js', '!./src/dist/*.js', '!./src/inject.js', '!./src/js/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('scripts', ['lint'], function () {
gulp.src(['src/dist/common.js', 'src/recipes/*Recipe.js', 'src/child_recipes/*Recipe.js', 'src/dist/recorder.js'])
.pipe(concat('src/inject.js'))
.pipe(uglify())
.pipe(gulp.dest('./'));
});
gulp.task('watchjs', function () {
gulp.watch(['./src/**/*.js', '!./src/inject.js', '!./src/options/*.js'], ['scripts']);
gulp.watch(['src/background.js', 'src/contentscript.js', 'src/common.js', 'src/recorder.js'], ['urls-dev', 'scripts']);
});
gulp.task('urls-dev', ['lint'], function () {
gulp.src(['./src/background.js', './src/contentscript.js', './src/common.js', './src/recorder.js'])
.pipe(preprocess({context: {DEBUG: true}}))
.pipe(gulp.dest('./src/dist/'));
});
gulp.task('dev', ['lint', 'scripts', 'urls-dev', 'watchjs']);
gulp.task('urls-prod', function () {
gulp.src(['./src/background.js', './src/contentscript.js', './src/common.js', './src/recorder.js'])
.pipe(preprocess())
.pipe(gulp.dest('./src/dist/'));
});
gulp.task('crx', function () {
return gulp.src('./src')
.pipe(crx({
privateKey: fs.readFileSync('./repeatit.pem', 'utf8'),
filename: manifest.name + '-' + manifest.version + '.crx'
}))
.pipe(gulp.dest('./build'));
});
gulp.task('prod', ['lint', 'urls-prod', 'scripts', 'crx']);
/* jshint ignore:end*/