Skip to content

Instantly share code, notes, and snippets.

@muratsplat
Last active August 30, 2015 21:04
Show Gist options
  • Select an option

  • Save muratsplat/db1cc9b98e1d8cd27e48 to your computer and use it in GitHub Desktop.

Select an option

Save muratsplat/db1cc9b98e1d8cd27e48 to your computer and use it in GitHub Desktop.

Revisions

  1. muratsplat renamed this gist Aug 30, 2015. 1 changed file with 0 additions and 0 deletions.
  2. muratsplat created this gist Aug 30, 2015.
    54 changes: 54 additions & 0 deletions A Elixir Task For Full Suport AngularJs + Babel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    //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!'));
    });
    });