# gulp-from-config-rg

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

Latest version **0.0.7** (published 2018-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-from-config-rg
pnpm add gulp-from-config-rg
yarn add gulp-from-config-rg
bun add gulp-from-config-rg
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-10-25 |
| First published | 2017-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 46.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | rg team |
| Maintainers | greensleeves, kamil.ocean, mrlozchka |
| Keywords | gulp, config, gulpfriendly |

## Links

- npm: https://www.npmjs.com/package/gulp-from-config-rg
- Repository: https://github.com/RGRU/gulp-from-config-rg
- Homepage: https://github.com/RGRU/gulp-from-config-rg#readme
- Issues: https://github.com/RGRU/gulp-from-config-rg/issues
- npm.io page: https://npm.io/package/gulp-from-config-rg

## Dependencies (10)

- [glob](https://npm.io/package/glob.md) 5.0.14
- [path](https://npm.io/package/path.md) 0.12.7
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [watchify](https://npm.io/package/watchify.md) 3.5.0
- [gulp-util](https://npm.io/package/gulp-util.md) 3.0.6
- [browserify](https://npm.io/package/browserify.md) 11.2.0
- [file-exists](https://npm.io/package/file-exists.md) 0.1.1
- [gulp-jshint](https://npm.io/package/gulp-jshint.md) 1.11.2
- [vinyl-buffer](https://npm.io/package/vinyl-buffer.md) 1.0.0
- [vinyl-source-stream](https://npm.io/package/vinyl-source-stream.md) 1.1.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2018-10-25
- 0.0.6 — 2018-10-24
- 0.0.4 — 2017-12-26
- 0.0.3 — 2017-12-22
- 0.0.2 — 2017-12-22
- 0.0.1 — 2017-12-22

## 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](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

```bash
# 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:

```bash
# 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

```javascript

// 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):

```bash
# This command will search for build task and run it
$ gulp build
```

## Usage

```javascript
'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

```javascript
{
    "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

```javascript
{
    ...
    "subTasks": [
        "watch": true
    ]
    ...
}
```
> Example default watch

```javascript
{
    ...
    "subTasks": [
        "watch": {
            dev: true,
            prod: false
        }
    ]
    ...
}
```
> Example watch in dev environment

```javascript
{
    ...
    "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

```javascript
{
    ...
    "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
```javascript
{
    ...
    "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

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