Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    gulp-config2public

    gulp config

    npm install --save-dev gulp-config2

    Easier to use

    No longer have to write code, configuration only

    import gconf from 'gulp-config2'
    gconf({
      'gulp-sass': {
        src: 'src/**/*.*',
        dest: 'public',
        options: {}
      }
    })

    Reuse your tasks

    If you would like to write some task yourself, it can be exactly the same to the NPM modules tasks/myTask.js

    import through from 'through2'
    export default function(options) {
      return through.obj(function (chunk, enc, cb) {
        cb(null, dealWithTheChunk(chunk, options))
      })
    })

    gulpfile.js

    gconf({
      'myTask': {
        task: './tasks/myTask',
        src: 'src/**/*.*',
        dest: 'public',
        options: {}
      }
    })

    Try to use src/dest/options through functions

    Usage:

    Add a built-in copy task, copy clean are ready to use.

    gconf({
      copy: {
        src: 'src/**/*.*',
        dest: 'public'
      }
    })

    It's exactly the same to this gulp task:

    gulp.task('copy', function () {
      return gulp.src('src/**/*.*')
        .pipe(gulp.dest('public'))
    })

    Add a task from a NPM module gulp-sass

    gconf.load('gulp-mocha')
    gconf({
      'gulp-mocha': {
        src: 'src/**/*.spec.js',
        // some options 
      }
    })

    It's exactly the same to this gulp task:

    gulp.task('gulp-mocha', function () {
      return gulp.src('src/**/*.spec.js')
        .pipe(require('gulp-mocha')(/*some options*/))
    })

    Add a renamed tasks

    gconf({
      dest: 'public',
      'custom-copy': {
        task: './tasks/copy'
        src: ['src/**/*.js'],
        dest: 'dist',//overwrote the global dest 
      },
      'sass': {
        task: 'gulp-sass',
        src: ['src/sass/index.scss']
      }
    })

    Config a task with multiple entries

    gconf.load('copy')
    gconf({
      'copy': {
        files: [{
            src: ['src1/**/*.js'],
            dest: 'dist1',
          },{
            src: ['src2/**/*.js'],
            dest: 'dist2',
        }]
      }
    })

    Add a queue task

    gconf.queue({
      mirror: [
        'clean',
        'copy'
      ]
    })
     
    gconf({
      mirror: {
        'clean': {
          src: [
            'public/images',
            'public/webfont',
          ]
        },
        'copy': [{
          src: 'src/assets/images',
          dest: 'public/images'
        },{
          src: 'node_modules/webfont/**/*.*',
          dest: 'public/webfont'
        }]
      }
    })

    Add a pipeline task

    gconf.pipelines({
      css: ['gulp-sass', 'gulp-prefix']
    })
     
    gconf({
      dest: 'public',
      css: {
        src: 'src/*.css',
        dest: 'dist', //otherwise use the global dest 
        'gulp-sass': {
          // options 
        },
        'gulp-prefix': {
          // options 
        }
      }
    })

    It's exactly the same to this gulp task:

    gulp.task('css', function () {
      return gulp.src('src/*.css')
        .pipe(require('gulp-sass')(/*sometions*/))
        .pipe(require('gulp-prefix')(/*sometions*/))
        .pipe(gulp.dest('public'))
    })

    Add multiple tasks

    gconf
    .load('copy', 'browserify', 'gulp-sass', 'gulp-autoprefixer', 'gulp-jshint')
     
    gconf({
      src: ['src/**/*.js'], //for simple projects 
      dest: 'dist', //for simple projects 
      'gulp-jshint': {
        node: true
      }
    })

    For complex and bigger projects

    Create sub-project rules for special folders like: src.project.myModule

    // TODO 
    gconf.project('project', {
      default: 'myModule',
      //src: src.project.myModule, 
      dest: 'public',
      'project-copy': {
        src: ''
      }
    })

    Keywords

    install

    npm i gulp-config2

    Downloadslast 7 days

    3

    version

    1.0.0-rc

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar