gulp-site-config v1.4.0
gulp-site-config
A simple Gulp plugin used for generating a single configuration file from subconfiguration files.
Usage
After including the plugin, pipe your subconfiguration files over to the gulp-site-config
plugin. When piping, make sure you declare an empty object to store the configuration object. This will pass the object by reference and update its contents. This is needed due to the linear workflow of Gulp.
Example
var gulp = require( 'gulp' ),
config = require( 'gulp-site-config' ),
jade = require( 'gulp-jade' );
var siteConfig = {};
gulp.task( 'loadSiteConfig', function() {
return gulp.src( 'src/**/_data.json' )
.pipe( config( siteConfig ) );
} );
gulp.task( 'jade', [ 'loadSiteConfig' ], function() {
return gulp.src( 'src/**/*.jade' )
.pipe( jade( { locals: siteConfig } ) )
.pipe( gulp.dest( 'site' ) );
} );
gulp.task( 'default', [ 'jade' ] );
API
##siteConfig( configVar, opts )
The plugin. Yep. configVar
is an object ( it can be empty or not. It'll be overwrriten anyway ) that stores the configuration object in. If this argument isn't specified, it'll throw an error.
opts
are options that do cool things. Look below.
##opts.resolve
If you don't like how the configuration file is structured, you can resolve the directory structure. For instance,
say we have the followig Vinyl File
object:
File( {
base: /home/jeremy/Devel/project/src/,
path: /home/jeremy/Devel/project/src/_data.json,
contents: ...
} );
This file would have the following configuration:
{
data: {
...
}
}
Say you wanted src
to be included in the config object. Just pass in
config( siteConfig, { resolve: '..' } );
You can resolve as much as you want, but you probably want to keep your object structure sane.