AngularJS : automate process to minify project

2019-08-13 23:51发布

问题:

I have this interest in automate/simplify angular project with a compiler tool, which might work on everything else, but angular inject and namespacing is awkward enough to escape compiler knowledge. What is the best/professional method for doing this?

thanks, just one last thing,

app.controller('ctrl',['$rootScope',function($rootScope){
    ...
}]);

works when minified, but how do I minify

app.config(['$routeProvider', function($routeProvider){

}]);

and does it work when I minify successive actions?

app.controller(...).directive(...).run(...)

回答1:

Check the ngmin (https://github.com/btford/ngmin) to automatically add Dependency-Injection annotations to AngularJS project. After this is done you should be able to use any JavaScript minifier.



回答2:

For each method you are chaining, use the brackets - exactly like you thought.

app.config(['$routeProvider', function($routeProvider){ }]).run(['$http', '$rootScope',  function($http, $rootScope){ }]);