1.0.0 • Published 8 years ago

gulp-target v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

gulp-target

Merge multiple directories by dependencies to build WL or variants of the project.

Install

$ npm install --save-dev gulp-target

Usage

Base project structure

/targets
/targets/targetA - dir of the target `targetA`
/targets/targetB - dir of the target `targetB`

Target must have target.json file. These config is using for merge process.

Example:

{
  "dependencies": [
    "common"
  ]
}

Adding this into your Gulpfile.js:

var gulp = require('gulp');
var target = require('gulp-target');

Sample usage

gulp.task('target', function () {

  var currentTarget = new target('targetName');

  return gulp.src([]) // some special files not from targets folders
    
    .pipe(currentTarget.pipe()) // <- files will be added here

    .pipe(gulp.dest('.target'))
    .on('error', function () {
      process.exit(1)
    });

});

Merging files

gulp.task('target', function () {

  var currentTarget = new target('targetName');

  return gulp.src([]) // some special files not from targets folders
    
    .pipe(currentTarget.pipe())

    .pipe($.if('config.json', $.extend('config.json', { strict: true }))
    .pipe(gulp.dest('.target'))
    .on('error', function () {
      process.exit(1)
    });

});

target.json

dependencies - are the names of the folders inside targetFolder. They will be included by order in the target.json.

Options

baseDir - name of the folder, there targets are located. targets by default

configName - name of the target config file. target.json by default

var currentTarget = new target('targetName', {
  baseDir: 'target',
  configName: 'target.json'
});