-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
44 lines (38 loc) · 1.09 KB
/
gulpfile.babel.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
import del from 'del'
import gulp from 'gulp'
import lambda from 'gulp-awslambda'
import gutil from 'gulp-util'
import zip from 'gulp-zip'
import runSequence from 'run-sequence'
import webpack from 'webpack'
import config from './config.json'
gulp.task('clean', () => del('dist'))
gulp.task('webpack', done => {
webpack(require('./webpack.config.js'), (error, stats) => {
if(error) throw new gutil.PluginError('webpack', error)
gutil.log(stats.toString({
chunks: false
}))
done()
})
})
gulp.task('zip', () => {
return gulp.src('dist/*')
.pipe(zip('index.zip'))
.pipe(gulp.dest('dist'))
})
gulp.task('build', done =>
runSequence('clean', 'webpack', 'zip', done)
)
gulp.task('default', ['build'], () =>
gulp.src('dist/index.zip')
.pipe(lambda({
FunctionName: config.AWS.LAMBDA_FUNCTION_NAME,
Handler: config.AWS.LAMBDA_HANDLER,
MemorySize: config.AWS.LAMBDA_MEMORY_SIZE,
Role: `arn:aws:iam::${config.AWS.ACCOUNT_ID}:role/lambda_basic_execution`,
Timeout: config.AWS.LAMBDA_TIMEOUT
},{
region: config.AWS.LAMBDA_REGION
}))
)