title: Concat javascript files under a single file
body: <p>File structure. </p>
  
  <pre><code>/app 
    /components 
       /core 
          /extensions
             - array.js 
             - string.js
          /services
             - logger.js 
          /lib 
             - core.js 
  </code></pre>
  
  <p><strong>Core.js</strong></p>
  
  <pre><code>(function() {
       'use strict';
       angular.module('app.core',[]);  
  }());
  </code></pre>
  
  <p>What i need is to  overwrite core.js on each build by copying all the other js files in that folder on to it, while keeping this first original content of the module deceleration. </p>
  
  <p>This is the wanted result for Core.js :</p>
  
  <pre><code>(function() {
       'use strict';
       angular.module('app.core',[]);  
  }());
  // content of array.js
  (function() {
     'use strict';
  
      var core = angular.module('app.core');
      core.config( .....) 
   }());     
  
   // content of string.js
   ...
   // content of logger.js
  </code></pre>
  
  <p>Iv'e tried 2 grunt tasks which i believed where men't for this purpose but did not find a way the configure them to my needs. </p>
  
  <p>1) grunt-concat had 2 issues the first that it appends the contents from the start of the file and not the end of the file like i wanted. and it does not override the existing content. </p>
  
  <p>2) grunt-copy does override but it overrides the entire file. </p>
  
  <p>What iv'e attempted is to use the process function for grunt copy.</p>
  
  <pre><code>  copy: {
        src: ['app/components/core/{,*/}*.js'],
        dest: 'app/components/core/lib/core.js',
        options:{
            process : function(content, srcpath){
                return content; // do some manipulation on content here. 
            }
        }         
    }
  </code></pre>
  
  <p>This is also problematic since i would have to keep the text that comprises the angular module definition in my Gruntfile and append it to the first content that comes into my process function, something like this which seems really messy.   </p>
  
  <pre><code> process : function(content, srcpath){
                if(isFirst) {
                    isFirst = false;
                    // here i will append the angular module deceleration. 
                }
                return content;
            }
  </code></pre>
  
  <p>Is there an elegant way to achieve what iv'e described ? </p>