-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
54 lines (45 loc) · 1.36 KB
/
gulpfile.babel.js
File metadata and controls
54 lines (45 loc) · 1.36 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
import gulp from 'gulp';
import gutil from 'gulp-util';
import browserify from 'browserify';
import babelify from 'babelify';
import uglify from 'gulp-uglify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import shell from 'gulp-shell';
// Input file.
var bundler = browserify('src/jsx/app.jsx', {
extensions: ['.js', '.jsx'],
debug: true,
standalone: 'amUI'
});
// Babel transform
bundler.transform(babelify.configure({
sourceMapRelative: 'src',
presets: ["es2015", "react"]
}));
// On updates recompile
bundler.on('update', bundle);
function bundle() {
return bundler.bundle()
.on('error', function (err) {
console.log("=====");
console.error(err.toString());
console.log("=====");
this.emit("end");
})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('public/assets/js'))
;
}
gulp.task('js', () => bundle());
gulp.task('upload', shell.task([
'aws s3 cp public/assets s3://apps.kbia.org/am-static-assets --recursive --profile kbia'
]));
gulp.task('deploy', ['js', 'upload']);
gulp.task('watch',function(){
gutil.log('Gulp will say that this task has finished, but don\'t believe its dirty lies.');
gutil.log('Hit \^c to actually exit watch mode.');
gulp.watch('src/**/*.jsx',['js']);
});