$ npm i --save-dev gulp-angular-module-dependencies
This module helps you to find all Angular.js
modules declared in your project and automatically add them as dependencies to the main app module.
Preserve all declared dependencies and the declaration order.
var gulp = require('gulp');
var moduleDependencies = require('gulp-angular-module-dependencies');
gulp.task('add-dependencies', function(){
return gulp.src(['app.js', 'module.js'])
.pipe(moduleDependencies('myApp'))
.pipe(gulp.dest('./'));
})
The app.js
angular.module('myApp', ['ui-router']);
angular.module('myApp').controller(function(){/*...*/});
The module.js
angular.module('myApp.module', ['ngResources']);
angular.module('myApp.anotherModule', ['ngAnimate']);
Only app.js
is modified into the following output:
angular.module('myApp',[
'myApp.anotherModule',
'myApp.module',
'ui-router'
]);
angular.module('app').controller(function () {/*...*/ });
moduleDependencies([moduleName], [options])
moduleName string default: app
The module where add all dependencies found.
options object default: {}
The options object with the following options:
options.angularObjectName string default: angular