-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gulpfile.js
80 lines (68 loc) · 1.79 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
const gulp = require('gulp');
const bump = require('gulp-bump');
const zip = require('gulp-zip');
const fs = require('fs');
const path = require('path');
const rimraf = require('gulp-rimraf');
const rename = require('gulp-rename');
const cheerio = require('gulp-cheerio');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var del = require('del');
const babel = require('gulp-babel');
const getPackageJson = function () {
return JSON.parse(fs.readFileSync('./manifest.json', 'utf8'));
};
gulp.task('bump', () => gulp.src('./manifest.json')
.pipe(bump({ type: 'patch' }))
.pipe(gulp.dest('./')));
gulp.task('remove', cb => {
gulp.src('./Chrome Notepad*.zip', { read: false }) // much faster
.pipe(rimraf());
cb();
});
function clean(cb) {
del(['dist']);
cb();
}
gulp.task('concat', function() {
return gulp.src(
["./js/ga.js", "./js/jquery.min.js",
"./js/jquery-ui.min.js", "./tinymce/js/tinymce/tinymce.min.js", "./js/utils.js",
"./js/model.js", "./js/actions.js",
"./js/shareView.js", "./js/view.js"]
)
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(concat('dist.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('compress', function (cb) {
gulp.src('./dist/dist.js')
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
cb();
});
gulp.task('zip', cb => {
gulp.src([
'./css/**',
'./icons/**',
'./js/**',
'./dist/**',
'./tinymce/**',
'./manifest.json',
'./background.js',
'./options.html',
'./popup.html',
], { base: '.' })
.pipe(zip(`Chrome Notepad ${getPackageJson().version.replace(/\./gi, '-')}.zip`))
.pipe(gulp.dest('./'));
cb();
});
gulp.task('minify',
gulp.series(clean, 'concat', 'compress')
);
gulp.task('default',
gulp.series('bump', 'remove', 'zip')
);