-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
108 lines (92 loc) · 3.5 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'use strict';
var gulp = require('gulp');
var clean = require('gulp-clean');
var cleanCss = require('gulp-clean-css');
var minify = require('gulp-minify');
var zip = require('gulp-zip');
var crx = require('gulp-crx-pack');
var sequence = require('run-sequence');
var fs = require('fs');
gulp.task('clean', function() {
return gulp.src('./build/*', {read: false})
.pipe(clean());
});
gulp.task('clean-directories', function() {
gulp.src('./build/chrome/*', {read: false})
.pipe(clean());
gulp.src('./build/edge/*', {read: false})
.pipe(clean());
gulp.src('./build/firefox/*', {read: false})
.pipe(clean());
return gulp.src('./build/global/*', {read: false})
.pipe(clean());
});
gulp.task('copy-global', function() {
return gulp.src(['./src/**', '!./src/img/src/**', '!./src/img/icon_old.png'])
.pipe(gulp.dest('./build/global/'));
});
gulp.task('compress-css', function () {
return gulp.src('./build/global/css/*.css')
.pipe(cleanCss())
.pipe(gulp.dest('./build/global/css/'));
});
gulp.task('compress-js', function () {
return gulp.src('./build/global/js/*.js')
.pipe(minify({
ext:{
min:'.js'
},
noSource: true,
ignoreFiles: ['*.min.js', '*-min.js']
}))
.pipe(gulp.dest('./build/global/js/'));
});
gulp.task('copyChrome', function() {
return gulp.src(['./build/global/**', './manifests/chrome/**/*'])
.pipe(gulp.dest('./build/chrome/'));
});
gulp.task('copyEdge', function() {
return gulp.src(['./build/global/**', './manifests/edge/*'])
.pipe(gulp.dest('./build/edge/'));
});
gulp.task('copyFirefox', function() {
return gulp.src(['./build/global/**', './manifests/firefox/**/*'])
.pipe(gulp.dest('./build/firefox/'));
});
gulp.task('build', function() {
var manifestChrome = require('./manifests/chrome/manifest.json'),
manifestEdge = require('./manifests/edge/manifest.json'),
manifestFirefox = require('./manifests/firefox/manifest.json'),
distFileName = manifestChrome.name + ' v' + manifestChrome.version;
var codebase = manifestChrome.codebase;
gulp.src("build/firefox/**/**/*")
.pipe(zip(distFileName + '.xpi'))
.pipe(gulp.dest('./build'));
gulp.src("build/edge/**/**/*")
.pipe(zip(distFileName + ' Edge' +'.zip'))
.pipe(gulp.dest('./build'));
gulp.src("build/chrome/**/**/*")
.pipe(zip(distFileName + ' Opera' +'.zip'))
.pipe(gulp.dest('./build'));
return gulp.src('./build/chrome/')
.pipe(crx({
privateKey: fs.readFileSync('./key/key.pem', 'utf8'),
filename: manifestChrome.name + ' v' + manifestChrome.version + '.crx',
codebase: codebase,
}))
.pipe(gulp.dest('./build'));
});
gulp.task('build-dev', function() {
sequence('clean', 'copy-global', 'copyChrome', 'copyEdge', 'copyFirefox', 'build', 'clean-directories');
});
gulp.task('default', ['build-dev']);
gulp.task('build-prod', function() {
sequence('clean', 'copy-global', 'compress-css', 'compress-js', 'copyChrome', 'copyEdge', 'copyFirefox', 'build', 'clean-directories');
});
gulp.task('build-prod-no-js-compress', function() {
sequence('clean', 'copy-global', 'compress-css', 'copyChrome', 'copyEdge', 'copyFirefox', 'build', 'clean-directories');
});
gulp.task('build-prod-no-css-compress', function() {
sequence('clean', 'copy-global', 'compress-js', 'copyChrome', 'copyEdge', 'copyFirefox', 'build', 'clean-directories');
});
gulp.task('clean-build', ['clean']);