├── .gitignore ├── index.js ├── package.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .DS_Store 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var concat = require('gulp-concat'); 3 | var sourcemaps = require('gulp-sourcemaps'); 4 | var jshint = require('gulp-jshint'); 5 | var stylish = require('jshint-stylish'); 6 | var uglify = require('gulp-uglify'); 7 | var ngAnnotate = require('gulp-ng-annotate'); 8 | var notify = require('gulp-notify'); 9 | var gulpif = require('gulp-if'); 10 | 11 | var Elixir = require('laravel-elixir'); 12 | 13 | var Task = Elixir.Task; 14 | 15 | Elixir.extend('angular', function(src, output, outputFilename) { 16 | 17 | var baseDir = src || Elixir.config.assetsPath + '/angular/'; 18 | 19 | new Task('angular in ' + baseDir, function() { 20 | var onError = function(err) { 21 | notify.onError({ 22 | title: "Laravel Elixir", 23 | subtitle: "Angular Compilation Failed!", 24 | message: "Error: <%= error.message %>", 25 | icon: __dirname + '/../laravel-elixir/icons/fail.png' 26 | })(err); 27 | 28 | this.emit('end'); 29 | }; 30 | 31 | // Module inits have to be included first. 32 | return gulp.src([baseDir + "*module.js", baseDir + "**/*module.js", baseDir + "**/*.js"]) 33 | .pipe(jshint()) 34 | .pipe(jshint.reporter(stylish)) 35 | .pipe(jshint.reporter('fail')).on('error', onError) 36 | .pipe(gulpif(! config.production, sourcemaps.init())) 37 | .pipe(concat(outputFilename || 'app.js')) 38 | .pipe(ngAnnotate()) 39 | .pipe(gulpif(config.production, uglify())) 40 | .pipe(gulpif(! config.production, sourcemaps.write())) 41 | .pipe(gulp.dest(output || config.jsOutput)) 42 | .pipe(notify({ 43 | title: 'Laravel Elixir', 44 | subtitle: 'Angular Compiled!', 45 | icon: __dirname + '/../laravel-elixir/icons/laravel.png', 46 | message: ' ' 47 | })); 48 | }).watch(baseDir + '/**/*.js'); 49 | 50 | }); 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-elixir-angular", 3 | "version": "1.0.1", 4 | "description": "Laravel Elixir AngularJS Extension", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "laravel", 11 | "elixir", 12 | "angluar", 13 | "angularJS", 14 | "gulp" 15 | ], 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/HRcc/laravel-elixir-angular" 19 | }, 20 | "author": "HRcc", 21 | "license": "MIT", 22 | "homepage": "https://github.com/HRcc/laravel-elixir-angular", 23 | "bugs": { 24 | "url": "https://github.com/HRcc/laravel-elixir-angular/issues" 25 | }, 26 | "dependencies": { 27 | "gulp-concat": "^2.3.3", 28 | "gulp-concat-sourcemap": "^1.3.1", 29 | "gulp-if": "^1.2.5", 30 | "gulp-jshint": "^1.9.0", 31 | "gulp-ng-annotate": "^1", 32 | "gulp-notify": "^2.0.0", 33 | "gulp-sourcemaps": "^1", 34 | "gulp-uglify": "^1", 35 | "jshint-stylish": "^2" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # [DEPRECATED] 2 | I would personally recommend to use Browserify or Webpack. It scales much better and it's not forcing any paricular structure to your code. 3 | 4 | ## Usage 5 | 6 | This is a simple wrapper around Laravel Elixir. Add it to your Elixir-enhanced Gulpfile, like so: 7 | 8 | ``` 9 | var elixir = require('laravel-elixir'); 10 | 11 | require('laravel-elixir-angular'); 12 | 13 | elixir(function(mix) { 14 | mix.angular(); 15 | }); 16 | ``` 17 | 18 | This will scan your `resources/assets/angular` directory for all .js files. Offers check of your source files by *JSHint*, generates *Sourcemaps*, concatenates and minifies (if environment is set to production) the final script. 19 | 20 | Directory structure in `resources/assets/angular` is not forced, the only limitation is to provide at least one **\*module.js** script with module initialization: 21 | 22 | ``` 23 | var foo = angular.module('foo', []); 24 | ``` 25 | 26 | Example use of a nested structure might look like this: 27 | ``` 28 | /resources 29 | /angular 30 | foo.module.js 31 | /some-feature 32 | some-feature.module.js 33 | some-feature.controller.js 34 | ``` 35 | 36 | Finally, if you'd like to output to a different directory than the default `public/js`, then you may override this, while changing the name of resulting script if desired: 37 | 38 | ``` 39 | mix.angular("resources/assets/angular/", "public/js/angular/", "application.js"); 40 | ``` 41 | --------------------------------------------------------------------------------