grunt-module-index
v0.1.7
Published
Auto-build module index file (exports) based on folders and files.
Downloads
9
Readme
grunt-module-index
Grunt task to auto-build module index files (exports) based on folders and files.
Getting Started
This plugin requires Grunt ~0.4.0
.
Install this grunt plugin with:
npm install grunt-module-index --save-dev
Then add this line to your project's grunt.js
Gruntfile:
grunt.loadNpmTasks('grunt-module-index');
Tests
To do.
Options
format
Type: String
Values: coffee
, js
Default: js
File format and extension.
indentTab
Type: String
Default: ' '
(2 spaces)
Indentation characters.
notice
Type: String
Optional file header message.
omitDirs
Type: Array|String
Default: []
Omit these directory names for the object hierarchy.
Example: omitDirs: ['src']
pathPrefix
Type: String
Optional prefix for every file path.
Example: pathPrefix: './'
and a file in src/
ends as require('./src/...
requireWithExtension
Type: Boolean
Default: false
Include file extensions on require
calls.
flatIndex
Type: Boolean
Default: false
Object hierarchy omits every directory.
Examples
Basic (javascript)
moduleIndex: {
build: {
src: ["src/"],
options: {
omitDirs: ["src"]
}
}
}
Full (coffee)
moduleIndex:
build:
src: ["modules/**/*.js", "components", "mixins/"]
dest: "index.coffee"
options:
format: "coffee"
indentTab: "\t"
notice: "Generated with grunt"
omitDirs: ["src"]
pathPrefix: "./"
requireWithExtension: true
Output example
//! This file was auto-generated by grunt-module-index, DO NOT edit it directly
module.exports = exports = {
components: {
nav: {
nav: require("components/nav/nav"),
navItem: require("components/nav/navItem")
},
form: {
button: require("components/form/button"),
input: require("components/form/input")
}
}
};
//EOF
License
Copyright (c) 2014-2015 Ignacio Lago
Licensed under the MIT license.