gulp-dir-concat
v0.0.1
Published
concat directory files
Downloads
41
Maintainers
Readme
gulp-wrap
A gulp plugin to concat files of the directories.
Usage
Firstly, install gulp-dir-concat
as a development dependency:
npm install gulp-dir-concat --save
Then, add it into your gulpfile.js
:
concat all files according to each directory:
const dirConcat = require("gulp-dir-concat");
gulp.src("./src/**/*.js")
.pipe(dirConcat())
.pipe(gulp.dest("build"));
concat the same file type of files according to each directory:
const path = require('path');
const gulpif = require('gulp-if');
const dirConcat = require("gulp-dir-concat");
function fileTypeOf(type) {
return function (file) {
return path.extname(file.path) === '.' + type;
};
}
gulp.src("./src/**/*")
.pipe(gulpif(fileTypeOf('css'),concat({
fileWaterMark: true //output comment of the original file name into the concated file
})))
.pipe(gulp.dest("build"));
concat all files into only one concated file:
const dirConcat = require("gulp-dir-concat");
gulp.src("./src/**/*.css")
.pipe(dirConcat({
concateIntoOne: true
}))
.pipe(gulp.dest("build"));
Parameters
fileWaterMark
Type: Boolean
Default: undefined
To output the comment of the original file name into the concated result.
concateIntoOne
Type: Boolean
Default: undefined
To concat files of all directory into only one file. Or it will concat files according each directory.
fileNameHandler
Type: Function
Default: undefined
Argument: { files: [], cwd: file.cwd, base: file.base}
To change the file name of the concated file by yourself.