grunt-part-builder
v0.1.3
Published
Grunt part builder helps creating big Grunt configuration by merging many parts. it permits complex build workflow
Downloads
3
Readme
grunt-part-builder
Grunt Part Builder - Merge multiple configuration parts, manage dependency, enable complex part building.
Getting Started
Install this grunt plugin next to your project's gruntfile with: npm install grunt-part-builder --save-dev
Then add this line to your project's Gruntfile.js
:
var partBuilder = require("grunt-part-builder");
Then specify a configuration for builder :
var builder = partBuilder.createBuilder(grunt, {
dev: grunt.option("dev") || false,
output: grunt.option("output") || "build"
});
Then build your configuration :
grunt.initConfig(builder.build());
Done, you can now build with custom tasks :
grunt --parts=part1,part2
Note: If no parts specified, grunt-part-builder search for a default part
Creating parts
To create configuration parts, create a parts folder in your project dir. Add your configuration chunks into this directory.
You can specifiy a different directory by setting prefix in input options
A part is simply a chunk of Grunt configuration. All parts chunks area merged during build. Arrays are merged, object are extended and dependencies are loaded.
Static configuration
Simply exports an object representing your Grunt configuration.
module.exports = {
dependencies: ["dep1", "dep2"],
concat: { /* ... */ },
cssmin: { /* ... */ },
copy: { /* ... */ },
watch: { /* ... */ },
// ...
};
Dynamic configuration
Return a function which take an argument and return a Grunt configuration chunk. The argument is the configuration which is given to builder during its creation.
module.exports = function(options) {
var includeDev = [];
if (options.dev)
includeDev.push("dev1.js", "dev2.js");
return {
dependencies: ["dep3"],
concat: { /* ... */ },
cssmin: { /* ... */ },
copy: {
main: {
src: ["file1.js", "file2.js"].concat(includeDev)
}
}
};
};
Release History
- 0.1.0 Initial Release
- Build multiple parts
- Apply dependencies
- Create custom options to pass to parts
- Allow objects and function parts