how to write advanced concat grunt script that find matches in seperate folders?


I need to write an advanced concat script using grunt. here is my boilerplate:

___js |____dist | |____vents | | |____commonEvents.js | | |____compare.js |____libs |____src | |____events | | |____carousel.common.js | | |____compare.js | | |____styles.common.js | |____handlers | | |____carousel.common.js | | |____compare.js | | |____style.common.js

I want the concat task to look into "src/events" and "src/handlers" directory and find all the files ending with ".common.js" and concat them together and put them in the "dist/vents" directory ("commonEvents.js"), other files that are not ending with ".common.js" I want the script to find the pair in the other directory and concat them together and put them into "dis/vents/filename.js" (example: events/compare.js and handlers/compare.js are pair and not ending with common.js).


I guess that we already know about <a href="https://github.com/gruntjs/grunt-contrib-concat" rel="nofollow">https://github.com/gruntjs/grunt-contrib-concat</a> module. You just need two different tasks. What about this:

grunt.initConfig({ concat: { common: { src: ['src/events/**/*.common.js', 'src/handlers/**/*.common.js'], dest: 'dist/vents/commonEvents.js' }, nocommon: { src: ['src/events/**/*.js', 'src/handlers/**/*.js', '!src/events/**/*.common.js', '!src/handlers/**/*.common.js'], dest: 'dist/vents/filename.js' } } });


I don't think there is anything similar ready to use.

If you plan to create your own solution, I think this package can be a good starting point:

<a href="https://github.com/yeoman/grunt-usemin" rel="nofollow">https://github.com/yeoman/grunt-usemin</a>

It manipulates the config of other plugins as well.


  • React-router, onEnter cause infinite loop with authentication
  • How to open a new view on button click in sencha touch 2
  • What is the benefit of using extend on the prototype in three.js inheritance pattern?
  • Script tag is loading from file:/// instead of http://
  • RegistryKey.GetSubKeyNames returns names that are not in that subkey!
  • Binary trees in scheme
  • How to repeat sections of a SQL query across UNIONs? (DRY in SQL)
  • my tic-tac-toe program in matlab does not work [closed]
  • Local Development, Apache vs Developer - file permissions
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • Less Conflicting Session Manager for Zope 2
  • cell spacing in div table
  • How do I formally document a C# Attribute in UML?
  • Unable to send e-mail through Java
  • Creating a DropDownList
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Implicit joins and Where in Doctrine - how?
  • AndEngine Applying Transparancy to AndEngine View
  • converting text file into xml using php?
  • Does Mobilefirst provide a provision to access web services directly?
  • Apache RewriteRule redirection with url encoded
  • Unable to get column index with table.getColumn method using custom table Model
  • custom UITableViewCell with image for highlighting
  • Parsing a CSV string while ignoring commas inside the individual columns
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • Display images in Django
  • How to attach a node.js readable stream to a Sendgrid email?
  • Change Inet root folder for iis 7
  • Java: can you cast Class into a specific interface?
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Different response to non-authenticated users and AJAX calls
  • Resize panoramic image to fixed size
  • AES padding and writing the ciphertext to a disk file
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Importing jscolor library in angular 2
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • How does Linux kernel interrupt the application?
  • Busy indicator not showing up in wpf window [duplicate]