'use strict';

const gulp = require('gulp');
const babel = require('gulp-babel');
const webpack = require('gulp-webpack');
const rename = require('gulp-rename');
const uglifyjs = require('gulp-uglifyjs');

gulp.task('default', () => {
  return gulp
    .start('build')
    .start('build:browser');
});

gulp.task('build', () => {
  return gulp.src('src/**')
    .pipe(babel({
        presets: ['es2015']
    }))
    .pipe(gulp.dest('lib'));
});

gulp.task('build:browser', () => {
  return gulp.src('src/**')
    .pipe(webpack(require('./webpack.config')))
    .pipe(gulp.dest('./dist'))
    .pipe(rename(path => path.extname = ".min.js"))
    .pipe(uglifyjs())
    .pipe(gulp.dest('./dist'));
});

@@ -683,16 +683,291 @@
 './dist'));%0A%7D);%0A
+%0Agulp.task('watch', () =%3E %7B%0A  return gulp.watch('src/*.js', e =%3E %7B%0A    if (e.type === 'changed') %7B%0A      console.log(%60$%7Be.path%7D changed, building...%60);%0A      %0A      gulp.src(e.path)%0A        .pipe(babel(%7B presets: %5B'es2015'%5D %7D))%0A        .pipe(gulp.dest('lib'));%0A    %7D%0A  %7D);%0A%7D)

add watch task