Time for my own AngularJS + Gulp + Browserify boilerplate
2014-05-02 10:25:20 +0000tl;dr: just visit my Github repo for a simple boilerplate with basic documentation.
I have found 36,749 examples of boilerplates using a miscellanea of AngularJS, Gulp, Browserify, Grunt, RequireJS and all the usual suspects.
But none of them actually did what I needed, although I reckon it is quite simple: define Angular modules in separate files, so the code is nice and clean and all the various services, directives and controllers are pluggable without massive headaches.
At the same time, having completely ignored the existence of Grunt so far (thanks to frontend guys who took care of this), I thought it was a good time for a fresh start with the latest and more fashionables Gulp and Browserify.
I ended up creating my own boilerplate (or seed, if you like), it works defining angular modules:
require('../../vendors/angular/angular'); module.exports = angular.module('boilerplate.controllers', []); // Just define the list of controllers here while developing the whole app (in this boilerplate, just one): require('./welcome.js');
using them:
require('../../vendors/angular/angular'); var module = require('./_module_init.js'); module.controller('WelcomeCtrl', ['$scope', function($scope) { console.log('welcome controller'); $scope.greetings = 'Hey!' }]);
and eventually compiling them in a single js
gulp.task('scripts', function() { return gulp.src('scripts/main/app.js') .pipe(browserify({ insertGlobals : true, debug : !isProduction })) .pipe(gulp.dest('build')) });
if anyone is interested, feel free to clone and submit pull requests!