-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
36 lines (28 loc) · 1.02 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
'use strict';
const del = require('del');
const gulp = require('gulp');
const zip = require('gulp-zip');
const merge = require('merge-stream');
const install = require('gulp-install');
const runSequence = require('run-sequence');
const awsLambda = require('node-aws-lambda');
const awsConfig = require('./aws-config'); // eslint-disable-line import/no-unresolved
gulp.task('clean', () => del(['dist/']));
gulp.task('bundle', () => gulp
.src('./package.json')
.pipe(gulp.dest('./dist'))
.pipe(install({ production: true })));
gulp.task('compile', () => {
const tasks = ['src'].map((directory) => gulp
.src(`${directory}/**/*`)
.pipe(gulp.dest(`./dist/${directory}`)));
return merge(tasks);
});
gulp.task('zip', () => gulp
.src('./dist/**/*', { nodir: true })
.pipe(zip('dist/dist.zip'))
.pipe(gulp.dest('./')));
gulp.task('upload', (callback) => {
awsLambda.deploy('./dist/dist.zip', awsConfig, callback);
});
gulp.task('deploy', (callback) => runSequence(['clean'], ['bundle'], ['compile'], ['zip'], callback));