Closed truemagic-coder closed 12 years ago
Yup, there are angularjs docs to solve this using commented provider names (placed immediately under controller function names) but only in reference to google's closure minifer. For uglifyjs support I've used this less agrssive but working minifying strategy:
uglifyjs --overwrite --no-copyright --no-mangle --verbose path/main.js
Uglifying is done within core:
https://github.com/meteor/meteor/blob/master/app/lib/bundler.js#L387
Fixing this isn't a one-liner it seems.
You can deploy with the --debug flag , this will disable uglify.
@lvbreda thanks for the tip
Why is it re-opned?
@lvbreda & @jasonkuhrt - Thanks!
Is there a good way to then minify the JS or must we do this using a third-party minifying engine?
To survive minification, injected dependencies must be annotated. See the "Dependency Annotation" section here: http://docs.angularjs.org/guide/di
In the above example, it would look like:
angular.module('controllers', []).controller('home', ['$scope', function($scope) {
...
}]);
@tsenying That works - thanks - but minification is still breaking the app.
A solution for the todos example:
Relevant solution for people using Grunt: http://stackoverflow.com/questions/17238759/angular-module-minification-bug
On deploy UglifyJS breaks Meteor-Angular: UglifyJS mangles $scope to a short variable name and thus breaks Angular controllers.
Error in JS Console: Unknown provider: eProvider <- e
Example (dev):
Example (prod)