Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:42:01+00:00 2026-06-12T08:42:01+00:00

To concatenate two files, it looks something like this: concat: { src: [‘common.js’,’js/app.js’], dest:

  • 0

To concatenate two files, it looks something like this:

  concat: {
    src: ['common.js','js/app.js'],
    dest: 'assets/js/app.js'
  }

And if I want to concat an entire folder of files into one, it looks something like this:

  concat: {
    src: ['dev/*.js','],
    dest: 'prod/js/app.js'
  }

But let’s say I have a file that I want to concat onto 10 or 20 other files, and I want them to concat separately? In other words, here is what I’m looking for:

A.js + B.js = AB.js
A.js + C.js = AC.js
A.js + D.js = AD.js
A.js + E.js = AE.js

And so on… To be more specific though, I can figure out how to concat files one by one as described, but I want to figure out how to specify A.js from the example, and have it concat onto any file in a specified path. So what I want is:

A.js + dev/*.js = AB.js, AC.js, AD.js, AE.js ...

In pseudo-code, here is what I want:

  concat: {
    src: ['common.js', 'dev/*.js','], // common.js gets concatenated to each file in this directory
    dest: 'prod/js/*.js' // each file in src gets saved separately in dest 
  }

I’d appreciate any help, I’ve have a hard time finding info on how to do this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:42:02+00:00Added an answer on June 12, 2026 at 8:42 am

    Grunt’s built-in concat task (I recommend looking at the source btw) does not support anything like dest: 'prod/js/*.js', you would have to specify each output target separately which is an overkill in your case.

    Your best bet is to just write your own code (perhaps wrap it in your custom task), it’s quite simple. Here’s a simple wrap multitask. Don’t promise it’s robust and safe to use 🙂

      grunt.registerMultiTask('wrap', 'Wraps source files with specified header and footer', function() {
            var data = this.data,
                path = require('path'),
                dest = grunt.template.process(data.dest),
                files = grunt.file.expandFiles(this.file.src),
                header = grunt.file.read(grunt.template.process(data.header)),
                footer = grunt.file.read(grunt.template.process(data.footer)),
                sep = grunt.utils.linefeed; 
    
            files.forEach(function(f) {
                var p = dest + '/' + path.basename(f),
                    contents = grunt.file.read(f);
    
                grunt.file.write(p, header + sep + contents + sep + footer);
                grunt.log.writeln('File "' + p + '" created.');
            });
      });
    

    Feed it with a config like this:

    wrap: {
        html: {
            header: '<%= project.partials %>/head.html',
            footer: '<%= project.partials %>/footer.html',
            src: [
                '<%= project.pages %>/index.html',
                '<%= project.pages %>/about.html',
                '<%= project.pages %>/blog.html'
            ],
            dest: '.'   // destination *directory*, probably better than specifying same file names twice
        }
    }
    

    Just in case I also updated your fiddle: http://jsfiddle.net/dipish/hKkGX/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to concatenate two files. I use Ant's exec for this purpose, but
I want to concatenate two files in android. I did this from the Terminal
I'm trying to concatenate two mp4 files using ffmpeg. I need this to be
If I use Dos command copy to concatenate two files: copy a1.txt + a2.txt
I am trying to concatenate two video files with the gnonlin components of the
I'm trying to concatenate two properties into one string like so: public class thing
I came across these two methods to concatenate strings: Common part: char* first= First;
Right, so I've managed to get my program to concatenate my two text files,
I have to concatenate these two strings from my resource/value files: <string name=Toast_Memory_GameWon_part1>you found
Suppose that you have two huge files (several GB) that you want to concatenate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.