I recommend a combination of two good grunt libraries, Wiredep and Usemin:
Wiredep: automatically download all bower dependencies identified in bower.json inside your html
Usemin: finding all src inside two comment tags and this whole source is minimized and combined into a dist folder, below is a small example of grunt files using these packages, based on the yoman angular generator, this is just a short of this grunt
Grunt
wiredep: { options: { cwd: 'appFolder' }, app: { src: ['htmlCollections'], ignorePath: /\.\.\// } }, useminPrepare: { html: 'htmlCollections', options: { dest: 'distributionFolder', flow: { html: { steps: { js: ['concat', 'uglifyjs'], css: ['cssmin'] }, post: {} } } } }, usemin: { html: ['distributionFolder+HtmlFiles'], css: ['distributionFolder+cssFiles'], js: ['distributionFolder+javascriptFiles'] }
HTML
<!doctype html> <html lang="en" ng-app="MobileDev" id="ng-app"> <head> //This gonna be generated for the grunt by dependencies in bower //All the script inside this gonna be concatened and minified in //the dist folder by the name of main.css <link type="text/css" rel="stylesheet" href="styles/app.css"/> </head> <body> //This gonna be generated for the grunt by dependencies in bower //And in distribution all bower components added gonna be minified by usemin in //vendor.js //All the script inside this gonna be concatened and minified in the dist //folder by the name of scripts.js <script type="text/javascript" src="scripts/numero1"></script> <script type="text/javascript" src="scripts/numero2"></script> </body>
Jesรบs quintana
source share