Skip to content

Instantly share code, notes, and snippets.

@muratsplat
Last active August 30, 2015 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muratsplat/db1cc9b98e1d8cd27e48 to your computer and use it in GitHub Desktop.
Save muratsplat/db1cc9b98e1d8cd27e48 to your computer and use it in GitHub Desktop.
Full support Angular + Babel + Modules + Uglify + Avoid issues of the Dependency Injection by helping ng-Annotate
//babelAngularExtention.js
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
/**
* These for Angular + Babel + Uglify + Avoid issues of the Dependency Injection
*/
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');;
var rename = require("gulp-rename");
var babelify = require('babelify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('gulp-buffer');
var gutil = require('gulp-util');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var babel = require('babel/register');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var $ = Elixir.Plugins;
var Task = Elixir.Task;
Elixir.extend('angularPlusBabel', function(opts) {
new Task('angularPlusBabel', function() {
var entries = opts.src;
var dist = opts.dist;
this.log(opts.src, opts.dist);
return browserify({
entries: entries,
debug: true
}).transform(babelify)
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe($.if(Elixir.config.production, ngAnnotate()))
.pipe($.if(Elixir.config.production, $.uglify()))
.on('error', function(e) {
new Elixir.Notification().error(e, 'angularPlusBabel Failed!');
this.emit('end');
})
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dist))
.pipe(new Elixir.Notification('angularPlusBabel Compiled!'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment