Created
May 12, 2016 19:18
-
-
Save corinna000/11c58812a55aaaf278c6fae01af2d79c to your computer and use it in GitHub Desktop.
Gulp + Babel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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