-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
63 lines (54 loc) · 1.63 KB
/
gulpfile.babel.js
File metadata and controls
63 lines (54 loc) · 1.63 KB
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
require('dotenv').config()
import gulp from 'gulp';
import gulpIf from 'gulp-if';
import path from 'path';
import runSequence from 'run-sequence';
import rename from 'gulp-rename';
import eslint from 'gulp-eslint';
import webpack from 'webpack';
import del from 'del';
import awspublish from 'gulp-awspublish';
import parallelize from 'concurrent-transform';
gulp.task('lint', () => {
return gulp.src(['src/**/*.js', '!node_modules/**'])
.pipe(eslint({ fix: false }))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('lint-fix', () => {
return gulp.src(['src/**/*.js', '!node_modules/**'])
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulpIf(file => file.eslint != null && file.eslint.fixed, gulp.dest('src/')))
.pipe(eslint.failAfterError());
});
gulp.task('publish', () => {
const publisher = awspublish.create({
region: process.env.AWS_S3_REGION,
params: {
Bucket: process.env.AWS_S3_BUCKET,
},
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});
const headers = {};
return gulp.src('./build/**/*')
.pipe(rename((p => {
p.dirname = path.join(process.env.AWS_S3_PATH, p.dirname);
})))
.pipe(awspublish.gzip())
.pipe(parallelize(publisher.publish(headers, {
force: true,
}), 8))
.pipe(publisher.cache())
.pipe(awspublish.reporter());
});
gulp.task('compile', (cb) => {
return webpack(require('./webpack.config.js'), cb);
});
gulp.task('clean', () => {
return del(['build']);
});
gulp.task('deploy', () => {
return runSequence('clean', 'compile', 'publish');
});