I'm new to packaging in JavaScript and to Angular.js. I've realised how npm and bower along with Karma can be really useful for deployment, testing, package management, etc. I use Ant, composer, PHP Unit and Jenkins in PHP projects so I understand the general concept.
My question / discussion is regarding minification in Google Closure and more generally building and deployment of an Angular.js app. A good starting point is the following line I added to my package.json file under "scripts": "prepublish": "rm app/js/app.build.min.js; java -jar node_modules/google-closure-compiler/compiler.jar --angular_pass --compilation_level ADVANCED_OPTIMIZATIONS --externs node_modules/google-closure-compiler/contrib/externs/angular-1.4.js --externs node_modules/google-closure-compiler/contrib/externs/angular_ui_router.js --js_output_file app/js/app.build.min.js './app/js/**.js'" I also added the following under "devDependencies": "google-closure-compiler": "~20151015.0.0" This seems quite useful because it enables me to combine all js for an app into one file ready for deployment and all by running <code>npm install</code>. It means I don't have to keep changing includes in my index file and I get a compressed file to load on execution. I've noticed issues with this method however; I can't select google closure externs automatically based on bower config so I need to define a particular version of angular.js, ui-router, etc and update these manually each time I make a change. This script also expects a particular directory structure so it isn't very portable. I could always configure this for each app I create though and I usually use the same directory structure from the angular-ui-seed skeleton. I've heard that it's best to avoid <code>ADVANCED_OPTIMIZATIONS</code> and externs so would like to know if anyone uses similar tools in production or why using this externs and ADVANCED_OPTIMIZATIONS is a bad idea? I've heard of tools such as Grunt and Ant being used in JavaScript building, testing and deployment and was wondering if someone could explain what the best method of automating this sort of minification would be? Are npm scripts okay or are they too limited to use in real world production? Also is Google Closure even the best tool to use for minification or are there better tools out there more suited to my requirements? UglifyJs is one I keep seeing. I'd really appreciate if someone could point me in the right direction for automating tasks specifically for Angular JS projects and whether npm scripts are sufficient or if you'd recommend I took another approach completely. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
