-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
52 lines (46 loc) · 1.37 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
const { series } = require('gulp');
const fs = require('fs');
const gulp = require('gulp');
const zip = require('gulp-zip');
const webpack = require('webpack');
const merge = require('merge-stream');
const webpackConfig = require('./webpack.config.js')
const filesToCopy = [
'package.json',
'icon.png',
'LICENSE.md',
'README.md'
];
function clean(cb) {
fs.rmdir('./package', { recursive: true }, (err) => {
if (err) { console.log('Clean', err) }
cb();
});
}
function build(cb) {
webpack({...webpackConfig, mode: 'production' }, (err, stats) => {
if (err) { console.log('Webpack', err) }
console.log(stats.toString({ /* stats options */ }))
cb();
});
}
function stage() {
const streams = filesToCopy.map(file => {
if (fs.existsSync(file)) {
return gulp.src(file).pipe(gulp.dest('package/analytics'));
}
}).filter(s => s != undefined);
return merge([
...streams,
gulp.src('dist/**/*').pipe(gulp.dest('package/analytics/dist')),
gulp.src('static/**/*').pipe(gulp.dest('package/analytics/static')),
]);
}
function package() {
return gulp.src('package/**/*').pipe(zip('extension.fplx')).pipe(gulp.dest('.'));
}
exports.clean = clean;
exports.build = build;
exports.stage = stage;
exports.package = package;
exports.default = series(clean, build, stage, package);