'use strict'

var gulp = require('gulp');
var watch = require('gulp-watch');
var babel = require('gulp-babel');
let sourcemaps = require('gulp-sourcemaps');
let uglify = require('gulp-uglify');

gulp.task('transform', () => {
  return gulp.src('server/**/*.js') // 匹配server文件夹下面的所有js文件
    .pipe(sourcemaps.init())  //
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist/server')); // 写入 'dist/server/'文件夹下
});

gulp.task('watch', () => {
  return gulp.src('server/**/*.js')
    .pipe(watch('server/**/*.js', {
      verbose: true
    }))
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(uglify({ mangle: false }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist/server/'));
});

// 执行transform任务
gulp.task('default', () => {
  gulp.start('transform');
});


liuoomei
175 声望18 粉丝

走出舒适区,外面的风景格外迷人!