Skip to content

Instantly share code, notes, and snippets.

@yabbes
Forked from alkrauss48/gulpfile.js
Created August 9, 2017 20:45
Show Gist options
  • Save yabbes/214b71f8b1295c9f7824fce17ffeafc6 to your computer and use it in GitHub Desktop.
Save yabbes/214b71f8b1295c9f7824fce17ffeafc6 to your computer and use it in GitHub Desktop.
Base gulpfile config for babel, browserify, and uglify - with sourcemaps and livereload
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
gulp.task('build', function () {
// app.js is your main JS file with all your module inclusions
return browserify({entries: './src/js/app.js', debug: true})
.transform("babelify", { presets: ["es2015"] })
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/js'))
.pipe(livereload());
});
gulp.task('watch', ['build'], function () {
livereload.listen();
gulp.watch('./src/js/*.js', ['build']);
});
gulp.task('default', ['watch']);
npm install --save-dev babel-preset-es2015 babelify browserify vinyl-source-stream vinyl-buffer gulp-uglify gulp-sourcemaps gulp-livereload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment