-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
51 lines (45 loc) · 1.4 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var gulp = require('gulp');
var join = require('path').join;
var rimraf = require('rimraf');
var babel = require('gulp-babel');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var PATH = {
src : 'src/',
dest : 'dist/',
demo : 'demo/'
};
gulp.task('clear', function (next) {
rimraf(PATH.dest, next);
});
gulp.task('build', ['clear'], function () {
return browserify(join(PATH.src, 'index.js'), {
debug: true,
standalone: 'FrontLog'
})
.transform('babelify', {
presets: ['es2015', 'stage-0'],
plugins: ['transform-es2015-modules-commonjs']
})
.bundle()
.on('error', function(err) {
console.log('----------------------------------');
console.error(err);
console.log('----------------------------------');
this.emit('end');
})
.pipe(source('front-log.js'))
.pipe(buffer())
.pipe(gulp.dest(join(PATH.demo)))
.pipe(gulp.dest(join(PATH.dest)))
.pipe(uglify())
.pipe(rename('front-log.min.js'))
.pipe(gulp.dest(join(PATH.dest)));
});
gulp.task('watch', ['build'], function() {
gulp.watch(join(PATH.src, '**/*.js'), ['build']);
});
gulp.task('default', ['build']);