-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
132 lines (119 loc) · 3.66 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
var gulp = require('gulp'),
minify = require('gulp-minify'),
html = require('gulp-htmlmin'),
css = require('gulp-clean-css'),
zip = require('gulp-zip'),
crx = require('gulp-crx-pack'),
clean = require('gulp-clean'),
eslint = require('gulp-eslint'),
moment = require('moment'),
vfs = require('vinyl-fs');
// clean build folder
gulp.task('clean', () => {
return gulp.src('build/*', {read: false})
.pipe(clean());
});
// clean target folder
gulp.task('clean-builds', () => {
return gulp.src('target/*', {read: false})
.pipe(clean());
})
// copy static folders
gulp.task('copy', () => {
gulp.src('src/img/**')
.pipe(gulp.dest('build/img'));
gulp.src('src/_locales/**')
.pipe(gulp.dest('build/_locales'));
gulp.src('src/manifest.json')
.pipe(gulp.dest('build'));
return gulp.src(['./node_modules/vue/**/*',
'./node_modules/clipboard/**/*',
'./node_modules/jquery/**/*',
'./node_modules/moment/**/*',
'./node_modules/semantic-ui-progress/**/*',
'./node_modules/font-awesome/**/*',
'./node_modules/kitsu/**/*'], {base: './'})
.pipe(gulp.dest('./build/'));
});
// Init workspace -- loading unpacked without this will make the extension crash
gulp.task('copy-devel', () => {
return gulp.src(['./node_modules/vue/**/*',
'./node_modules/clipboard/**/*',
'./node_modules/jquery/**/*',
'./node_modules/moment/**/*',
'./node_modules/semantic-ui-progress/**/*',
'./node_modules/font-awesome/**/*',
'./node_modules/kitsu/**/*'], {base: './'})
.pipe(gulp.dest('./src/'));
});
// html
gulp.task('html', () => {
return gulp.src('src/pages/*.html')
.pipe(html({collapseWhitespace: true}))
.pipe(gulp.dest('build/pages'));
});
// css
gulp.task('css', () => {
return gulp.src('src/css/*.css')
.pipe(css())
.pipe(gulp.dest('build/css'));
});
// JS
gulp.task('js', () => {
gulp.src('src/websites/*.js')
.pipe(minify({
ext: {
src: '.js',
min: '.js'
},
preserveComments: 'some',
noSource: true
}))
.pipe(gulp.dest('build/websites'));
gulp.src('src/pages/*.js')
.pipe(minify({
ext: {
src: '.js',
min: '.js'
},
preserveComments: 'some',
noSource: true
}))
.pipe(gulp.dest('build/pages'));
return gulp.src('src/*.js')
.pipe(minify({
ext: {
src: '.js',
min: '.js'
},
preserveComments: 'some',
noSource: true
}))
.pipe(gulp.dest('build'));
});
gulp.task('lint', () => {
return gulp.src(['src/*.js', 'src/pages/*.js', 'src/websites/*'])
.pipe(eslint())
.pipe(eslint.format('stylish', process.stdout))
})
// build and zip
gulp.task('zip/crx/xpi', ['copy', 'html', 'css', 'js'], () => {
var manifest = require('./src/manifest.json'),
filename = 'Kitsu Web Scrobbler v' + manifest.version + ' ' + moment().format('D-MMM-YYYY-HH-mm-ss');
gulp.src('build/**')
.pipe(zip(filename + '.zip'))
.pipe(gulp.dest('target'));
/*gulp.src('build/**')
.pipe(crx({
filename: filename + '.crx',
privateKey: null // set private key here or it will not build"openssl genrsa -out private.pem 2048" should works
}))
.pipe(gulp.dest('target'));*/
return gulp.src('build/**')
.pipe(zip(filename + '.xpi'))
.pipe(gulp.dest('target'));
});
gulp.task('default', ['clean', 'lint'], () => {
gulp.start('zip/crx/xpi');
return true;
});