# gulp-concat

> Concatenates files

Latest version **2.6.1** (published 2016-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-concat
pnpm add gulp-concat
yarn add gulp-concat
bun add gulp-concat
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.6.1 |
| Published | 2016-11-13 |
| First published | 2013-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-concat) |
| Module format | CommonJS |
| Node | >= 0.10 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 776 |
| Author | Contra |
| Maintainers | contra, fractal |
| Keywords | gulpplugin |

## Links

- npm: https://www.npmjs.com/package/gulp-concat
- Repository: https://github.com/contra/gulp-concat
- Homepage: https://github.com/contra/gulp-concat#readme
- Issues: https://github.com/contra/gulp-concat/issues
- npm.io page: https://npm.io/package/gulp-concat

## Dependencies (3)

- [vinyl](https://npm.io/package/vinyl.md) ^2.0.0
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [concat-with-sourcemaps](https://npm.io/package/concat-with-sourcemaps.md) ^1.0.0

## Recent versions

- 2.6.1 (latest) — 2016-11-13
- 2.6.0 — 2015-06-23
- 2.5.2 — 2015-02-21
- 2.5.1 — 2015-02-20
- 2.5.0 — 2015-02-15
- 2.4.3 — 2014-12-28
- 2.4.2 — 2014-11-19
- 2.4.1 — 2014-09-16
- 2.4.0 — 2014-09-06
- 2.3.5 — 2014-09-03
- 2.3.4 — 2014-07-22
- 2.3.3 — 2014-07-09
- 2.3.0 — 2014-07-08
- 2.2.0 — 2014-03-17
- 2.1.7 — 2014-01-03
- … 11 more at https://npm.io/package/gulp-concat/versions

## README

![status](https://secure.travis-ci.org/contra/gulp-concat.svg?branch=master)

## Installation

Install package with NPM and add it to your development dependencies:

`npm install --save-dev gulp-concat`

## Information

<table>
<tr>
<td>Package</td><td>gulp-concat</td>
</tr>
<tr>
<td>Description</td>
<td>Concatenates files</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.10</td>
</tr>
</table>

## Usage

```js
var concat = require('gulp-concat');

gulp.task('scripts', function() {
  return gulp.src('./lib/*.js')
    .pipe(concat('all.js'))
    .pipe(gulp.dest('./dist/'));
});
```

This will concat files by your operating systems newLine. It will take the base directory from the first file that passes through it.

Files will be concatenated in the order that they are specified in the `gulp.src` function. For example, to concat `./lib/file3.js`, `./lib/file1.js` and `./lib/file2.js` in that order, the following code will create a task to do that:

```js
var concat = require('gulp-concat');

gulp.task('scripts', function() {
  return gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js'])
    .pipe(concat('all.js'))
    .pipe(gulp.dest('./dist/'));
});
```

To change the newLine simply pass an object as the second argument to concat with newLine being whatever (\r\n if you want to support any OS to look at it)

For instance:

```js
.pipe(concat('main.js', {newLine: ';'}))
```

To specify `cwd`, `path` and other [vinyl](https://github.com/wearefractal/vinyl) properties, gulp-concat accepts `Object` as first argument:

```js
var concat = require('gulp-concat');

gulp.task('scripts', function() {
  return gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js'])
    .pipe(concat({ path: 'new.js', stat: { mode: 0666 }}))
    .pipe(gulp.dest('./dist'));
});
```

This will concat files into `./dist/new.js`.

### Source maps

Source maps can be generated by using [gulp-sourcemaps](https://www.npmjs.org/package/gulp-sourcemaps):

```js
var gulp = require('gulp');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('javascript', function() {
  return gulp.src('src/**/*.js')
    .pipe(sourcemaps.init())
      .pipe(concat('all.js'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('dist'));
});
```

---
_Source: https://npm.io/package/gulp-concat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
