How to handle bower_components when copy files to www


Using generator-ionic with grunt

the bower_components folders are copied as is to www and contain many unneeded files like the component .md, doc, test, samples etc, those get into the build and increase the image size and slow the development cycle. (in my case pouchdb had 33M selenium-server-standalone-2.38.0.jar which caused me problems)

Wonder if anyone can suggest a process/best practice how to know which files are needed and how to copy only the needed files?

Improve assets setup in ionic framework

No one on the ionic team worked on that generator and it is officially supported by us. You should probably open up an issue for that on that github page.



I have had the same kind of problem, this is how I solved it:

  • I have a dev and a build folder

  • I use ‘usemin’ to annotate which files should be concat and minified to a specific file
    <!-- build:js scripts/libraries.js -->

     <script src="bower_components/ionic/release/js/ionic.bundle.min.js"></script>
     <script src="bower_components/angular-resource/angular-resource.min.js"></script>
     <script src="bower_components/angular-touch/angular-touch.min.js"></script>
     <!-- endbuild -->
  • This copies only the needed library files to my build folder.

  • I did have to copy the Ionicons font, but that could be automated with Grunt aswell.

That’s how solved it, good luck with it