Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save corinna000/11c58812a55aaaf278c6fae01af2d79c to your computer and use it in GitHub Desktop.
Save corinna000/11c58812a55aaaf278c6fae01af2d79c to your computer and use it in GitHub Desktop.
Gulp + Babel
/**
* Generic Gulpfile for building small AngularJS modules. This does the *very minimum*
* amount of work to get a module to build.
* npm install --save-dev gulp gulp-concat gulp-uglify del babel babel-preset-es2015 gulp-babel
*/
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var config = require('./package.json');
var del = require('del');
var babel = require('gulp-babel');
// configure for your source files
var src = ['./src/**/*.module.js', './src/**/*.js', '!./src/**/*.spec.js'];
// reads the name of the module distributable from package.json
var match = config.main.match(/(.*)[/](.*)/);
var path = match[1];
var file = match[2];
gulp.task('clean', function () {
return del(path);
});
gulp.task('build', ['clean'], function () {
gulp
.src(src)
.pipe(babel({ presets: ['es2015']}))
.pipe(concat(file))
.pipe(uglify())
.pipe(gulp.dest(path));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment