-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.38 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
require('babel-polyfill');
const gulp = require('gulp');
const gutil = require('gulp-util');
const webpack = require('webpack');
const del = require('del');
const crx = require('gulp-crx-pack');
const fs = require('fs');
const webpackConf = require('./webpack.config.js');
const js = './src/*.js';
const css = './src/css/*.css';
const src = './src/**/*';
const libJS = './src/lib/*.js';
const excluedJS = '!./src/*.js';
const build = './build';
const pem = './build.pem';
const pack = 'zhihu-like-analyzer.crx';
gulp.task('clean', () => {
return del([build]);
});
gulp.task('copy', ['clean'], (cb) => {
gulp.src([src, excluedJS]).pipe(gulp.dest(build));
gulp.src(libJS).pipe(gulp.dest(build));
cb();
});
gulp.task('webpack', ['clean'], (cb) => {
webpack(webpackConf, (err, stats) => {
if (err) {
throw new gutil.PluginError('[webpack]', err);
} else {
gutil.log('[webpack]', stats.toString());
cb();
}
});
});
gulp.task('build', ['clean', 'copy', 'webpack'], (cb) => {
gulp.src(build)
.pipe(crx({
privateKey: fs.readFileSync(pem, 'utf8'),
filename: pack}))
.pipe(gulp.dest(build));
cb();
});
gulp.task('crx', function() {
return
});
gulp.task('watch', function () {
gulp.watch(css, ['webpack']);
gulp.watch(js, ['webpack']);
});
gulp.task('default', ['build']);