maluramichael
11/9/2015 - 1:30 PM

gulpfile.js

// use 'npm install --save-dev gulp browserify babel babelify babel-preset-react babel-preset-es2015 gulp-util vinyl-buffer vinyl-source-stream gulp-uglify gulp-sourcemaps'

var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var util = require('gulp-util');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('build', function() {
    browserify('./src/main.js', {
            debug: false
        })
        //.add(require.resolve('babel/polyfill'))
        .transform('babelify', {
            presets: ['es2015', 'react']
        })
        .bundle()
        .on('error', util.log.bind(util, 'Browserify Error'))
        .pipe(source('main.js'))
        .pipe(buffer())
        //.pipe(sourcemaps.init({
        //    loadMaps: true
        //}))
        //.pipe(uglify({
        //     mangle: false
        //}))
        // .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist'));
});

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