npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-from-config-rg

v0.0.7

Published

Library that helps you to build app with gulp from config file

Downloads

12

Readme

gulp-from-config-rg

gulp-from-config-rg provides ability to run gulp tasks from configs.

Version for rg stack, fork from https://github.com/nanomen/gulp-from-config

Why

  • Team work on the same project without risk of breaking other tasks
  • Store multiple typical tasks as configs
  • Write clear and specific to application gulpfile and keep routine tasks in configs

Caveats

  • tests and linter coverage needed

Install

# Don't forget to install gulp globaly
# $ sudo npm install -g gulp
$ npm install gulp gulp-from-config-rg

As simple as

Install plugins that you need:

# This command will install sass compiler for gulp
$ npm install gulp-sass --save-dev

Write tasks in JSON configs and place them in ./configs or any other folder


// Load gulp and gulp-from-config-rg
var gulp = require('gulp'),
    gulpFromConfig = require('gulp-from-config-rg');

    // Set config files path
    gulpFromConfig.setConfigsPath('configs');

    // Create tasks
    gulpFromConfig.createTasks(gulp);

Run them as any other gulp tasks from console (by task name):

# This command will search for build task and run it
$ gulp build

Usage

'use strict';

/**
 *  At the beginning load:
 *  - gulp
 *  - gulp-from-config-rg
 */
var gulp = require('gulp'),
    gulpFromConfig = require('gulp-from-config-rg')
    tasks = []; // declare tasks list array

    /**
     *  First option is to get tasks from configs
     *  and set path to files.
     *
     *  For example to ./configs directory
     */
    gulpFromConfig.setConfigsPath('configs');

    /**
     *  Or define config
     */
    var task = {
        expired: "07-22-2018" // task expired date
        name: "styles", // module task name
            subTasks: [
                {
                    name: "sass", // technical task name
                    dest: "/dest/css", // path to build
                    sourcemaps: true, // enable sourcemaps
                    src: {
                        include: [
                            "/src/sass/*.sass" // files to proceed
                        ],
                        exclude: [
                            "/src/sass/_*.sass" // files to ignore
                        ]
                    },
                    plugins: [
                        {
                            "name": "gulp-sass", // gulp-sass plugin
                            "options": {
                                "outputStyle": "compressed" // will be passed to plugin parameter
                            }
                        }
                    ]
                }
            ]
    };

    /**
     *  And pass it as Array to setConfigs function
     */
    gulpFromConfig.setConfigs([task]);

    /**
     *  Callback function can be triggered on completion of subtasks
     *  Sub task config is passed as parameter
     */
    var callback = function(config) {
        console.log('Sub task config:', config);
    }
    gulpFromConfig.setCallback(callback);

    /**
     *  Define tasks based on configs
     *  Run like normal gulp task 'gulp styles'
     */
    tasks = gulpFromConfig.createTasks(gulp);

    /**
     *  Or if you need to run all of them
     *  pass tasks array to default task
     *  and run 'gulp'
     */
    gulp.task('default', tasks, function() {
        console.log('All tasks are done!');
    });

Example gulpfile.jsmake sure installing them

parameters

If you want run task without expire date, add --no_expire parameter or alias --ne. For example, sudo -u admin gulp tmpl --expire

--no_expire(--ne) parameter

If you want run task without gulp-imagemin plugin, add --imgmin=no parameter. For example, sudo -u admin gulp tmpl --imgmin=no

--imgmin=no parameter

config

{
    "name": "production", // task name which can be called by 'gulp production'
    "subTasks": [
        {
            "name": "script", // sub task name
            "dest": "/dest/js", // for gulp.dest('/dest/css')
            "sourcemaps": false, // if sourcemaps are required
            "browserify": {
                "transform": ["ractivate"] // Set extra browserify transforms (make sure that transform installed!)
                "file": "prod.js" // You can specify file name. Will be task name by default ('production')
            },
            "watch": {
                // watch if environment: dev
                dev: [ // if array is empty will watch src files
                    "/src/js/*.js", // watch changes on source files
                    "/src/js/_*.js"
                ],
                // unwatch if environment: prod
                prod: false
            },
            "src": {
                "include": [
                    "/src/js/*.js" // will be processed
                ],
                "exclude": [
                    "/src/js/_*.js" // will be ignored
                ]
            },
            "plugins": [
                {
                    "name": "gulp-uglify", // gulp-uglify plugin (make sure that plugin installed!)
                    "options": {
                        "mangle": false // will be passed into gulp.pipe(uglify(options))
                    }
                }
            ]
        },
        {
            "similarSubTask",
            "dest" "~",
            "src": "~", // use ~ to get any props from previous subtasks
            "plugins": [
                "~gulp-uglify" // use ~PLUGIN_NAME if you wish to copy this plugin config from previous subtask (or use plugins: "~" to repeat all pugins)
            ]
        }
    ]
};

Example production.json

watch option examples

{
    ...
    "subTasks": [
        "watch": true
    ]
    ...
}

Example default watch

{
    ...
    "subTasks": [
        "watch": {
            dev: true,
            prod: false
        }
    ]
    ...
}

Example watch in dev environment

{
    ...
    "subTasks": [
        "watch": {
            dev: false, // unwatch in development mode
            prod: [ // if array is empty will watch src files
                "/src/js/*.js", // watch changes on source files
                "/src/js/_*.js"
            ]
        }
    ]
    ...
}

Example watch in prod environment

{
    ...
    "subTasks": [
        "watch":  [ // if array is empty will watch src files
            "/src/js/*.js", // watch changes on source files
            "/src/js/_*.js"
        ]
    ]
    ...
}

Example watch must be array

browserify option example

{
    ...
    "subTasks": [
        "watch": {
            dev: false, // unwatch in development mode
            prod: [ // if array is empty will watch src files
                "/src/js/*.js", // watch changes on source files
                "/src/js/_*.js"
            ]
        }
    ],
    "browserify": {
        "transforms": [
          {
            "name": "eslintify"
          },
          {
            "name": "ractivate",
            "options": {
              "extensions": [
                ".ihtml"
              ]
            }
          }
        ],
        "watchify": {
          "dev": true,
          "prod": false
        }
      },
    ...
}

Example browserify watch