Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iguntur/mild-config

:warning: [DEPRECATED] - Mild config for gulp
https://github.com/iguntur/mild-config

Last synced: about 12 hours ago
JSON representation

:warning: [DEPRECATED] - Mild config for gulp

Awesome Lists containing this project

README

        

# mild-config [![Build Status](https://travis-ci.org/iguntur/mild-config.svg?branch=master)](https://travis-ci.org/iguntur/mild-config)

> Mild config for gulp

Make easy and simple to setup __[gulp](https://www.npmjs.com/package/gulp)__ config tasks.

### Requirement

- __Node 4+__

## Install

``` bash
$ npm install --save mild-config
```

## Usage

``` js
const gulp = require('gulp');
const webpack = require('webpack-stream');
const sass = require('gulp-sass');
const config = require('mild-config');

gulp.task('script', () => {
return gulp.src(config.src('js/*.js'))
.pipe(webpack(config.get('plugins.webpack')))
.pipe(gulp.dest(config.dest('js')));
});

gulp.task('sass', () => {
return gulp.src(config.src('sass/**/*.scss'))
.pipe(sass(config.get('plugins.sass')))
.pipe(gulp.dest(config.dest('css')));
});
```

## API

> Also See [dot-prop](https://www.npmjs.com/package/dot-prop#api) API

### config.Mild(options)

Returns a new instance

#### options

Type: `object`

- __default__

Type: `object`

Default config.

#### Instance

- __.set(key, value)__

Set an item.

- __.set(object)__

Set multiple items at once.

- __.get(key)__

Get an item.

- __.has(key)__

Check if an item exists.

- __.delete(key)__

Delete an item.

- __.clear()__

Delete all items.

- __.src(path)__

Return the `path` and include with prefix path `'resources/assets'`,

ensure the `path` does not begin with `'/'`, `'./'`, `'../'`.

__path__

Type: `string`, `array`

__Example__

``` js
const config = require('mild-config');

config.src('js/*.js');
//=> 'resources/assets/js/*.js'

config.src('./_assets/js/*.js');
//=> './_assets/js/*.js'

config.src(['js/*.js', '!js/vendor/**']);
//=> ['resources/assets/js/*.js', '!resources/assets/js/vendor/**']

config.src(['js/*.js', '!./node_modules/**']);
//=> ['resources/assets/js/*.js', '!./node_modules/**']
```

- __.dest(folder)__

Return the `folder` and include with prefix path `'public/assets'`,

ensure the `folder` does not begin with `'/'`, `'./'`, `'../'`.

__folder__

Type: `string`

Set your folder destination

__Example__

``` js
const config = require('mild-config');

config.dest('css');
//=> 'public/assets/css'

config.dest('./public/css');
//=> './public/css'
```

- __.join([...paths])__

Returns path using __[path.join](https://nodejs.org/api/path.html#path_path_join_paths)__

__paths__

Type: `string`

__Example__

``` js
const config = require('mild-config');

config.join('basePath', 'assetsPath', 'gulp.src.js', 'foo.js');
//=> 'resources/assets/scripts/foo.js'

var path = config.join('basePath', 'assetsPath', 'gulp.src.js', 'foo.js');

config.join('publicPath', 'assetsPath', 'gulp.dest.js');
//=> 'public/assets/js'
```

## Related

- [dot-prop](https://github.com/sindresorhus/dot-prop) - API for this module (Get, set, or delete a property from a nested object using a dot path)

## License

MIT © [Guntur Poetra](http://guntur.starmediateknik.com)