grunt-mixit
v0.2.1
Published
Mix data files into one
Downloads
13
Readme
grunt-mixit
Merge multiple json files.
It uses the mixit microlib.
If you want more power you should use the json-merge by maxogden
Getting Started
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-mixit --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-mixit');
The "mixit" task
Overview
In your project's Gruntfile, add a section named mixit
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
mixit: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Options
options.indent
Type: Number
Default value: 0
The number of spaces (up to 10) to use to indent the JSON.
Usage Examples
Default Options
grunt.initConfig({
mixit: {
files: {
'dist/foo.json': ['src/bar.json', 'src/baz.json'],
},
or: {
src: ['data/en/**/*.json'],
dest: 'dist/en.json'
}
},
})
Options
By default the generated JSON won't have any extra spaces. It will already be minified. If you want a prettier, say readable output you can use the indent
option, which is FYI, the third parameter of the JSON.stringify
method.
See jimcowart speaking about this function.
grunt.initConfig({
mixit: {
options: {
indent: 2
},
files: {
src: ['data/en/**/*.json'],
dest: 'dist/en.json'
},
},
})
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
(Nothing yet)
License
Copyright (c) 2014 Stéphane Bachelier. Licensed under the MIT license.