{"id":13623837,"url":"https://github.com/gruntjs/grunt-contrib-concat","last_synced_at":"2025-05-14T08:09:24.487Z","repository":{"id":4903346,"uuid":"6059428","full_name":"gruntjs/grunt-contrib-concat","owner":"gruntjs","description":"Concatenate files.","archived":false,"fork":false,"pushed_at":"2024-07-02T05:09:53.000Z","size":309,"stargazers_count":809,"open_issues_count":42,"forks_count":170,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-05-11T03:43:17.431Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"http://gruntjs.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"laravel-china/php-the-right-way","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gruntjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-10-03T12:01:39.000Z","updated_at":"2025-02-28T03:02:43.000Z","dependencies_parsed_at":"2023-07-05T18:02:06.764Z","dependency_job_id":"afc88920-5eb2-4157-a940-6bfd59a172f1","html_url":"https://github.com/gruntjs/grunt-contrib-concat","commit_stats":{"total_commits":151,"total_committers":32,"mean_commits":4.71875,"dds":0.8278145695364238,"last_synced_commit":"0c30da128b2d8b339f2c2246a823b38644713940"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-concat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-concat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-concat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruntjs%2Fgrunt-contrib-concat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gruntjs","download_url":"https://codeload.github.com/gruntjs/grunt-contrib-concat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-01T21:01:36.237Z","updated_at":"2025-05-14T08:09:19.478Z","avatar_url":"https://github.com/gruntjs.png","language":"JavaScript","funding_links":[],"categories":["hacktoberfest","Minifiers","Minifiers - JS \u0026 CSS"],"sub_categories":["Meetups"],"readme":"# grunt-contrib-concat v2.1.0 [![Build Status](https://github.com/gruntjs/grunt-contrib-concat/workflows/Tests/badge.svg)](https://github.com/gruntjs/grunt-contrib-concat/actions?workflow=Tests)\n\n\u003e Concatenate files.\n\n\n\n## Getting Started\n\nIf you haven't used [Grunt](https://gruntjs.com/) before, be sure to check out the [Getting Started](https://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](https://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-contrib-concat --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-contrib-concat');\n```\n\n\n\n\n## Concat task\n_Run this task with the `grunt concat` command._\n\nTask targets, files and options may be specified according to the Grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.\n\n### Options\n\n#### separator\nType: `String`  \nDefault: `grunt.util.linefeed`\n\nConcatenated 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.\n\n#### banner\nType: `String`  \nDefault: `''`\n\nThis string will be prepended to the beginning of the concatenated output. It is processed using [grunt.template.process][], using the default options.\n\n_(Default processing options are explained in the [grunt.template.process][] documentation)_\n\n#### footer\nType: `String`  \nDefault: `''`\n\nThis string will be appended to the end of the concatenated output. It is processed using [grunt.template.process][], using the default options.\n\n_(Default processing options are explained in the [grunt.template.process][] documentation)_\n\n#### stripBanners\nType: `Boolean` `Object`  \nDefault: `false`\n\nStrip JavaScript banner comments from source files.\n\n* `false` - No comments are stripped.\n* `true` - `/* ... */` block comments are stripped, but _NOT_ `/*! ... */` comments.\n* `options` object:\n  * By default, behaves as if `true` were specified.\n  * `block` - If true, _all_ block comments are stripped.\n  * `line` - If true, any contiguous _leading_ `//` line comments are stripped.\n\n#### process\nType: `Boolean` `Object` `Function`  \nDefault: `false`\n\nProcess source files before concatenating, either as [templates][] or with a custom function.\n\n* `false` - No processing will occur.\n* `true` - Process source files using [grunt.template.process][] defaults.\n* `data` object - Process source files using [grunt.template.process][], using the specified options.\n* `function(src, filepath)` - Process source files using the given function, called once for each file. The returned value will be used as source code.\n\n_(Default processing options are explained in the [grunt.template.process][] documentation)_\n\n  [templates]: https://github.com/gruntjs/grunt-docs/blob/master/grunt.template.md\n  [grunt.template.process]: https://github.com/gruntjs/grunt-docs/blob/master/grunt.template.md#grunttemplateprocess\n\n#### sourceMap\nType: `Boolean`  \nDefault: `false`\n\nSet 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.\n\n#### sourceMapName\nType: `String` `Function`  \nDefault: `undefined`\n\nTo 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.\n\n#### sourceMapStyle\nType: `String`  \nDefault: `embed`\n\nDetermines 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.\n\n### Usage Examples\n\n#### Concatenating with a custom separator\n\nIn this example, running `grunt concat:dist` (or `grunt concat` because `concat` is a [multi task][multitask]) will concatenate the three specified source files (in order), joining files with `;` and writing the output to `dist/built.js`.\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  concat: {\n    options: {\n      separator: ';',\n    },\n    dist: {\n      src: ['src/intro.js', 'src/project.js', 'src/outro.js'],\n      dest: 'dist/built.js',\n    },\n  },\n});\n```\n\n#### Banner comments\n\nIn 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`.\n\nThis 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.\n\n_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._\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  pkg: grunt.file.readJSON('package.json'),\n  concat: {\n    options: {\n      stripBanners: true,\n      banner: '/*! \u003c%= pkg.name %\u003e - v\u003c%= pkg.version %\u003e - ' +\n        '\u003c%= grunt.template.today(\"yyyy-mm-dd\") %\u003e */',\n    },\n    dist: {\n      src: ['src/project.js'],\n      dest: 'dist/built.js',\n    },\n  },\n});\n```\n\n#### Multiple targets\n\nIn 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`.\n\nWhile 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][multitask].\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  concat: {\n    basic: {\n      src: ['src/main.js'],\n      dest: 'dist/basic.js',\n    },\n    extras: {\n      src: ['src/main.js', 'src/extras.js'],\n      dest: 'dist/with_extras.js',\n    },\n  },\n});\n```\n\n#### Multiple files per target\n\nLike 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`.\n\nThis example differs in that both files are built under the same target.\n\nUsing the `files` object, you can have list any number of source-destination pairs.\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  concat: {\n    basic_and_extras: {\n      files: {\n        'dist/basic.js': ['src/main.js'],\n        'dist/with_extras.js': ['src/main.js', 'src/extras.js'],\n      },\n    },\n  },\n});\n```\n\n#### Dynamic filenames\n\nFilenames can be generated dynamically by using `\u003c%= %\u003e` delimited underscore templates as filenames.\n\nIn 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).\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  pkg: grunt.file.readJSON('package.json'),\n  concat: {\n    dist: {\n      src: ['src/main.js'],\n      dest: 'dist/\u003c%= pkg.name %\u003e-\u003c%= pkg.version %\u003e.js',\n    },\n  },\n});\n```\n\n#### Advanced dynamic filenames\n\nIn this more involved example, running `grunt concat` will build two separate files (because `concat` is a [multi task][multitask]). The destination file paths will be expanded dynamically based on the specified templates, recursively if necessary.\n\nFor 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.\n\n```js\n// Project configuration.\ngrunt.initConfig({\n  pkg: grunt.file.readJSON('package.json'),\n  dirs: {\n    src: 'src/files',\n    dest: 'dist/\u003c%= pkg.name %\u003e/\u003c%= pkg.version %\u003e',\n  },\n  concat: {\n    basic: {\n      src: ['\u003c%= dirs.src %\u003e/main.js'],\n      dest: '\u003c%= dirs.dest %\u003e/basic.js',\n    },\n    extras: {\n      src: ['\u003c%= dirs.src %\u003e/main.js', '\u003c%= dirs.src %\u003e/extras.js'],\n      dest: '\u003c%= dirs.dest %\u003e/with_extras.js',\n    },\n  },\n});\n```\n\n#### Invalid or Missing Files Warning\nIf you would like the `concat` task to warn if a given file is missing or invalid be sure to set `nonull` to `true`:\n\n```js\ngrunt.initConfig({\n  concat: {\n    missing: {\n      src: ['src/invalid_or_missing_file'],\n      dest: 'compiled.js',\n      nonull: true,\n    },\n  },\n});\n```\n\nSee [configuring files for a task](http://gruntjs.com/configuring-tasks#files) for how to configure file globbing in Grunt.\n\n\n#### Custom process function\nIf you would like to do any custom processing before concatenating, use a custom process function:\n\n```js\ngrunt.initConfig({\n  concat: {\n    dist: {\n      options: {\n        // Replace all 'use strict' statements in the code with a single one at the top\n        banner: \"'use strict';\\n\",\n        process: function(src, filepath) {\n          return '// Source: ' + filepath + '\\n' +\n            src.replace(/(^|\\n)[ \\t]*('use strict'|\"use strict\");?\\s*/g, '$1');\n        },\n      },\n      files: {\n        'dist/built.js': ['src/project.js'],\n      },\n    },\n  },\n});\n```\n\n[multitask]: http://gruntjs.com/creating-tasks#multi-tasks\n\n\n## Release History\n\n * 2022-04-03   v2.1.0   Updated dependencies\n * 2021-10-07   v2.0.0   Update dependencies Requires node.js v12+\n * 2016-04-20   v1.0.1   Fix for concatenating multiple source map files.\n * 2016-02-20   v1.0.0   Update source-map to 0.5.3. Tag Grunt as peerDep to \u003e=0.4.0. Make source maps generation a little faster. Add `charset:utf-8` to `sourceMappingURL`.\n * 2015-02-20   v0.5.1   Fix path issues with source maps on Windows.\n * 2014-07-19   v0.5.0   Adds `sourceMap` option.\n * 2014-03-21   v0.4.0   README updates. Output updates.\n * 2013-04-25   v0.3.0   Add option to process files with a custom function.\n * 2013-04-08   v0.2.0   Don't normalize separator to allow user to set LF even on a Windows environment.\n * 2013-02-22   v0.1.3   Support footer option.\n * 2013-02-15   v0.1.2   First official release for Grunt 0.4.0.\n * 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.\n * 2013-01-09   v0.1.2rc5   Updating to work with grunt v0.4.0rc5. Switching back to `this.files` API.\n * 2012-11-13   v0.1.1   Switch to `this.file` API internally.\n * 2012-10-03   v0.1.0   Work in progress, not yet officially released.\n\n---\n\nTask submitted by [\"Cowboy\" Ben Alman](http://benalman.com/)\n\n*This file was generated on Sun Apr 03 2022 07:55:57.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruntjs%2Fgrunt-contrib-concat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgruntjs%2Fgrunt-contrib-concat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruntjs%2Fgrunt-contrib-concat/lists"}