Indexed by TopGit from live GitHub metadata: gruntjs/grunt-contrib-concat has 796 stars, written primarily in JavaScript. Concatenate files.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-contrib-concat --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-contrib-concat');
Concat task
Run this task with the grunt concat command.
Task targets, files and options may be specified according to the Grunt Configuring tasks guide.
Options
separator
Type: String
Default: grunt.util.linefeed
Concatenated files will be joined on this string. If you're post-processing concatenated JavaScript files with a minifier, you may need to use a semicolon ';\n' as the separator.
banner
Type: String
Default: ''
This string will be prepended to the beginning of the concatenated output. It is processed using grunt.template.process, using the default options.
(Default processing options are explained in the grunt.template.process documentation)
footer
Type: String
Default: ''
This string will be appended to the end of the concatenated output. It is processed using grunt.template.process, using the default options.
(Default processing options are explained in the grunt.template.process documentation)
stripBanners
Type: BooleanObject
Default: false
Strip JavaScript banner comments from source files.
false - No comments are stripped.
true - /* ... */ block comments are stripped, but NOT/*! ... */ comments.
options object:
By default, behaves as if true were specified.
block - If true, all block comments are stripped.
line - If true, any contiguous leading// line comments are stripped.
process
Type: BooleanObjectFunction
Default: false
Process source files before concatenating, either as templates or with a custom function.
false - No processing will occur.
true - Process source files using grunt.template.process defaults.
data object - Process source files using grunt.template.process, using the specified options.
function(src, filepath) - Process source files using the given function, called once for each file. The returned value will be used as source code.
(Default processing options are explained in the grunt.template.process documentation)
sourceMap
Type: Boolean
Default: false
Set to true to create a source map. The source map will be created alongside the destination file, and share the same file name with the .map extension appended to it.
sourceMapName
Type: StringFunction
Default: undefined
To customize the name or location of the generated source map, pass a string to indicate where to write the source map to. If a function is provided, the concat destination is passed as the argument and the return value will be used as the file name.
sourceMapStyle
Type: String
Default: embed
Determines the type of source map that is generated. The default value, embed, places the content of the sources directly into the map. link will reference the original sources in the map as links. inline will store the entire map as a data URI in the destination file.
Usage Examples
Concatenating with a custom separator
In this example, running grunt concat:dist (or grunt concat because concat is a multi task) will concatenate the three specified source files (in order), joining files with ; and writing the output to dist/built.js.
In this example, running grunt concat:dist will first strip any preexisting banner comment from the src/project.js file, then concatenate the result with a newly-generated banner comment, writing the output to dist/built.js.
This generated banner will be the contents of the banner template string interpolated with the config object. In this case, those properties are the values imported from the package.json file (which are available via the pkg config property) plus today's date.
Note: you don't have to use an external JSON file. It's also valid to create the pkg object inline in the config. That being said, if you already have a JSON file, you might as well reference it.
In this example, running grunt concat will build two separate files. One "basic" version, with the main file essentially just copied to dist/basic.js, and another "with_extras" concatenated version written to dist/with_extras.js.
While each concat target can be built individually by running grunt concat:basic or grunt concat:extras, running grunt concat will build all concat targets. This is because concat is a multi task.
Like the previous example, in this example running grunt concat will build two separate files. One "basic" version, with the main file essentially just copied to dist/basic.js, and another "with_extras" concatenated version written to dist/with_extras.js.
This example differs in that both files are built under the same target.
Using the files object, you can have list any number of source-destination pairs.
Filenames can be generated dynamically by using <%= %> delimited underscore templates as filenames.
In this example, running grunt concat:dist generates a destination file whose name is generated from the name and version properties of the referenced package.json file (via the pkg config property).
In this more involved example, running grunt concat will build two separate files (because concat is a multi task). The destination file paths will be expanded dynamically based on the specified templates, recursively if necessary.
For example, if the package.json file contained {"name": "awesome", "version": "1.0.0"}, the files dist/awesome/1.0.0/basic.js and dist/awesome/1.0.0/with_extras.js would be generated.
2016-04-20 v1.0.1 Fix for concatenating multiple source map files.
2016-02-20 v1.0.0 Update source-map to 0.5.3. Tag Grunt as peerDep to >=0.4.0. Make source maps generation a little faster. Add charset:utf-8 to sourceMappingURL.
2015-02-20 v0.5.1 Fix path issues with source maps on Windows.
2014-07-19 v0.5.0 Adds sourceMap option.
2014-03-21 v0.4.0 README updates. Output updates.
2013-04-25 v0.3.0 Add option to process files with a custom function.
2013-04-08 v0.2.0 Don't normalize separator to allow user to set LF even on a Windows environment.
2013-02-22 v0.1.3 Support footer option.
2013-02-15 v0.1.2 First official release for Grunt 0.4.0.
2013-01-18 v0.1.2rc6 Updating grunt/gruntplugin dependencies to rc6. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
2013-01-09 v0.1.2rc5 Updating to work with grunt v0.4.0rc5. Switching back to this.files API.
2012-11-13 v0.1.1 Switch to this.file API internally.
2012-10-03 v0.1.0 Work in progress, not yet officially released.
Task submitted by "Cowboy" Ben Alman
This file was generated on Sun Apr 03 2022 07:55:57.
How active is development on gruntjs/grunt-contrib-concat?
The most recent commit recorded on gruntjs/grunt-contrib-concat was 2 months ago, based on the GitHub push timestamp. The repository has 167 forks — one of the better signals of community interest.
How many stars does gruntjs/grunt-contrib-concat have?
gruntjs/grunt-contrib-concat has 796 GitHub stars — refresh the page for the live number, or check github.com/gruntjs/grunt-contrib-concat. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is gruntjs/grunt-contrib-concat written in?
gruntjs/grunt-contrib-concat is written primarily in JavaScript. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is gruntjs/grunt-contrib-concat associated with?
GitHub's repository topics for gruntjs/grunt-contrib-concat: "hacktoberfest". TopGit's editorial category is open-source.
Where do I read more about gruntjs/grunt-contrib-concat?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/gruntjs/grunt-contrib-concat is the definitive source.
Read full README in the tab above.
Curious whether grunt-contrib-concat is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about grunt-contrib-concat.