Creating minified angularjs scripts requires an extra step to make sure all the dependancies are injected properly. The basic workflow is to concatenate all the angular scripts into one file, use ngmin to rewrite the script with the proper angular injections/syntax, then use Closure Compiler to minify the concatenated and altered angularjs script.
My projects follow the angular seed file structure, and when they grow are extended to follow the recommended layout for huge apps.
- Angularjs minify steps
- Concatenate all the angularjs files
$> cat app.js controllers/controller1.js controllers/controller2.js services/service1.js directives/directive1.js filters/filter1.js > concat.js -
install ngmin and run
$> ngmin concat.js concat.annotated.js -
finally use Closure Compiler to minify the angular project
$> java -jar compiler.jar --js concat.annotated.js --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file app.min.js
EDIT 9/8/13: You can automate minifying angularjs by using Grunt.