-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (60 loc) · 1.98 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
'use strict';
//npm install gulp del gulp-clean-css gulp-htmlclean gulp-jshint gulp-zip --save-dev
var gulp = require('gulp'),
del = require('del'),
htmlclean = require('gulp-htmlclean'),
cleanCSS = require('gulp-clean-css'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
zip = require('gulp-zip');
gulp.task('clean', function() {
return del(['build/**']);
});
//copy static folders to build directory
gulp.task('copy', function() {
gulp.src(['assets/*.png', 'assets/*.woff2'])
.pipe(gulp.dest('build/assets'));
gulp.src('assets/keys.json.private')
.pipe(rename('keys.json'))
.pipe(gulp.dest('build/assets'));
gulp.src('lib/*.js')
.pipe(gulp.dest('build/lib'));
return gulp.src('manifest.json')
.pipe(gulp.dest('build'));
});
gulp.task('html', function() {
return gulp.src('./*.html')
.pipe(htmlclean())
.pipe(gulp.dest('build'));
});
gulp.task('jshint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('scripts', ['jshint'], function() {
return gulp.src(['js/*.js'])
.pipe(gulp.dest('build/js'));
});
gulp.task('styles', function() {
return gulp.src('css/*.css')
.pipe(cleanCSS())
.pipe(gulp.dest('build/css'));
});
gulp.task('chrome', ['html', 'scripts', 'styles', 'copy'], function() {
var manifest = require('./manifest'),
distFileName = manifest.name + ' v' + manifest.version + '.zip';
return gulp.src(['build/**'])
.pipe(zip(distFileName))
.pipe(gulp.dest('dist'));
});
gulp.task('firefox', ['html', 'scripts', 'styles', 'copy'], function() {
var manifest = require('./manifest'),
distFileName = manifest.name + ' v' + manifest.version + '.xpi';
return gulp.src(['build/**'])
.pipe(zip(distFileName))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['clean'], function() {
gulp.start('chrome');
});