import gulp from 'gulp';
import gulpBabel from 'gulp-babel';
import gulpRimraf from 'gulp-rimraf';
import gulpEslint from 'gulp-eslint';
import gulpPlumber from 'gulp-plumber';
import gulpUtil from 'gulp-util';
import gulpMocha from 'gulp-mocha';
import webpack from 'webpack';

import webpackConfig from './webpack.config.babel';

const ROOT_PATH = __dirname;

const SOURCE_PATH = 'src/**/*.{js,jsx}';

const FILES_TO_CLEAN = [
  'public/*',
  '!public/editors',
  'api',
  'bundleEditor',
  'components',
  'componentEditors',
  'data',
  'runtime',
  'utils',
  'settingsEditors',
];

gulp.task('lint', () =>
  gulp.src([SOURCE_PATH, 'gulpfile.babel.js', 'webpack.config.babel.js'])
    .pipe(gulpEslint())
    .pipe(gulpEslint.format())
    .pipe(gulpEslint.failAfterError())
);

gulp.task('test', () => {
  return gulp.src(['test/**/*.js'], { read: false })
    .pipe(gulpMocha({ reporter: 'spec' }))
    .on('error', gulpUtil.log);
});

gulp.task('watch-test', () => {
  gulp.watch(['src/**', 'test/**'], ['test']);
});

gulp.task('webpack:build-dev', ['babel:build'], (callback) => {
  webpack(webpackConfig).run((err, stats) => {
    if(err) {
      throw new gulpUtil.PluginError('webpack:build-dev', err);
    }
    gulpUtil.log('[webpack:build-dev]', stats.toString({
      colors: true,
    }));
    callback();
  });
});

gulp.task('clean', () => {
  return gulp.src(FILES_TO_CLEAN)
    .pipe(gulpRimraf());
});

gulp.task('babel:build', () =>
  gulp.src(SOURCE_PATH)
    .pipe(gulpPlumber())
    .pipe(gulpBabel())
    .pipe(gulp.dest(ROOT_PATH))
);

gulp.task('webpack:build', ['babel:build', 'webpack:build-dev']);

gulp.task('build', ['babel:build', 'webpack:build-dev']);

gulp.task('watch', ['build'], () => {
  gulp.watch(SOURCE_PATH, ['babel:build', 'webpack:build-dev']);
});

gulp.task('default', ['lint', 'build']);

@@ -581,16 +581,440 @@
 s',%0A%5D;%0A%0A
+function buildWebpack(debug = false) %7B%0A  return (callback) =%3E %7B%0A    webpack(Object.assign(%7B%7D, webpackConfig, %7B%0A      debug,%0A      devtool: debug ? webpackConfig.devtool : false,%0A    %7D)).run((err, stats) =%3E %7B%0A      if(err) %7B%0A        throw new gulpUtil.PluginError('webpack:build-dev', err);%0A      %7D%0A      gulpUtil.log('%5Bwebpack:build-dev%5D', stats.toString(%7B%0A        colors: true,%0A      %7D));%0A      callback();%0A    %7D);%0A  %7D;%0A%7D%0A%0A
 gulp.tas
@@ -1496,264 +1496,97 @@
 '%5D, 
-(callback) =%3E %7B%0A  webpack(webpackConfig).run((err, stats) =%3E %7B%0A    if(err) %7B%0A      throw new gulpUtil.PluginError('webpack:build-dev', err);%0A    %7D%0A    gulpUtil.log('%5Bwebpack:build-dev%5D', stats.toString(%7B%0A      colors: true,%0A    %7D));%0A    callback();%0A  %7D);%0A%7D
+buildWebpack(true));%0Agulp.task('webpack:build-prod', %5B'babel:build'%5D, buildWebpack(false)
 );%0A%0A
@@ -1874,32 +1874,32 @@
 :build-dev'%5D);%0A%0A
-
 gulp.task('build
@@ -1908,32 +1908,95 @@
  %5B'babel:build',
+ 'webpack:build-prod'%5D);%0Agulp.task('build-dev', %5B'babel:build',
  'webpack:build-

Rename build in build-dev and now build is for prod