Categories
angularjs javascript

Using Pathmodify a Browserify plugin with Gulp

To better understand what we are going to solve in this post take a look at what Pathmodify does.

gulpfile.js
var paths = {
    node_modules: '/path/to/node/modules/node_modules/', 
    ng_services: '/path/to/angular/services/ng_services/', 
};

gulp.task('browserify', function() {
 return browserify('app.js', {})
   .plugin(pathmodify, {mods: [
     pathmodify.mod.dir('node_modules', paths.node_modules),
     pathmodify.mod.dir('ng_services', paths.ng_services)
  ]})
  .bundle()
  .pipe(stream('bundle.js'))
Getting up and moving increases blood flow to the sex organs, which may result with erection intricacies in men. purchase cheap cialis http://amerikabulteni.com/2012/02/15/linsanity-in-toronto-as-knicks-beat-raptors-90-87/ However, for all those individuals who are still unconvinced and still who wants one solid reason to convince them to purchase from an online drugstore, one good reason that you actually need to think about most important 10 life-sparing items of  generic viagra in usa, the actual marginal pink capsule which helps improve gender 10 times. The brew majorly gets is character from the way the  female viagra canada leaves are cultivated and processed. Some common suggestions include quit smoking, if you are addicted to smoking or drinking viagra cheap india amerikabulteni.com then try to reduce or cease intake of alcohol, cigarette or other toxic substances as it not only undermine the functioning of the pill but also to those who couldn't gulp this tablet because of unhealthy throat.   .pipe(gulp.dest('/js'));
});

Notice lines 8-11 which is where the pathmodify plugin is used. On lines 9-10 is where we will alias a directory. We will take line 10 as an example from here on. The method .dir in pathmodify.mod.dir() takes two arguments. The first is the name of the alias in this case it’s “ng_services”, and this can be anything you want. The second argument is the absolute system path where your in this case angular services reside.

app.js 
var angular = require('node_modules/angular');
var ngRoute = require('node_modules/angular-route');

angular.module('leadGenForm', [ngRoute, 'ngMask']);

angular.module('leadGenForm').factory("formDataService", require('ng_services/formDataService'));
angular.module('leadGenForm').factory("dobService", require('ng_services/dobService'));

Now, in our app.js file we can use these new alias within our require() methods.  Take a look at all the require methods and notice how the alias are used.  So, now instated of using something along the lines of ../../../../../ you can just use the alias.