-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
40 lines (35 loc) · 1.12 KB
/
gulpfile.babel.js
File metadata and controls
40 lines (35 loc) · 1.12 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
import gulp from 'gulp';
import eslint from 'gulp-eslint';
import browserify from 'browserify';
import babel from 'babelify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import sourcemaps from 'gulp-sourcemaps';
import uglify from 'gulp-uglify';
import gutil from'gulp-util';
gulp.task('browserify', ['lint', 'env:production'], () => {
let b = browserify('./src/js/index.js').transform(babel);
return b.bundle()
.pipe(source('index.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build/js'));
});
gulp.task('copy', () => {
return gulp.src('src/index.html')
.pipe(gulp.dest('build/'));
});
/* Set node env */
gulp.task('env:production', () => {
return process.env.NODE_ENV = 'production';
});
gulp.task('lint', () => {
return gulp.src(['./gulpfile.babel.js', './src/js/**/*'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('default', ['browserify', 'copy']);