npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-split

v0.2.1

Published

Grunt plugin that lets you break up your Gruntfile by feature

Downloads

8

Readme

#grunt-split

Grunt plugin that lets you split your gruntfile configuration into multiple files. You are not limited to defining one task per configuration file. Each file extends the configuration object meaning each file can contain a slice of the full configuration stack. This is particularly useful if you distribute a seed project in which you want separate features to be enabled or disabled from the build process.

##TL;DR

  • Each configuration file can contain any number of task configurations.
  • Configuration files are merged in the order in which they are included.
  • See the section on merge conflict resolution below for the merge rules.

##Installation

npm install -D grunt-split

##Grunt-Split Syntax

var loadConfig=require('grunt-split');
var settings={
	files: ['path/to/file.conf.js','path/to/another/file.conf.js']
};

var parameters={
	anyVariable: "you want to propagate to all the called scripts",
	I_find: "this a great place to specify folders in your project",
	folders: {
		bower: '/bower_components/',
		npm:'/npm_modules/'
	}
}

var config=loadConfig(settings,parameters)
// grunt.initConfig(config);
// Deprecated v0.2.0

config.initConfig();
// Can also call grunt.initConfig(config.getConfig()) since v0.2.0
	

##Separate Config File Syntax The object returned on module.exports for each of the split config files have 3 possible properties in the root object:

module.exports={
	npm_tasks:[],
	config: {},
	aliasses: {}
}

####npm_tasks This allows you to set the grunt dependencies for that particular configuration file. Any tasks listed in this array will be loaded using grunt.npmLoadTasks(). That way you can keep your grunt instance as thin as possible.

####config This is where the configuration lives. Configure any grunt plugins here keeping in mind how the merge-rules will determine how they merge with other configuration files.

####aliasses This is where you can specify grunt task aliasses that will be registered via grunt.registerTask(). #####syntax

module.exports={
	aliasses:{
		jobName:['task','task']
	}
}

##Example

module.exports = function(grunt) {

	var config=require('grunt-split')(grunt,{
		files:[
			'grunt/bootstrap.conf.js',
		//	'grunt/angular.conf.js',
			'grunt/font-awesome.conf.js',
		]
	});

	// grunt.initConfig(config); 
	// Deprecated v0.2.0

	config.initConfig();
	// Can also call grunt.initConfig(config.getConfig()) since v0.2.0
	

	grunt.registerTask('default',[]);
};

grunt/bootstrap.conf.js

module.exports = {
	npm_tasks:[
		'grunt-contrib-concat',
		'grunt-contrib-watch',
		'grunt-contrib-less'
	],
	config:{
		less:{
			bootstrap:{
				//bootstrap less compilation configuration goes here
			}
		},
		concat:{
			bootstrap:{
				//concatenate any css and javascript here
			}
		},
		watch:{
			bootstrap:{
				//instructions on what to watch
			}
		}
	},
	aliasses:{
		'watch_all',['watch:bootstrap']
	}
}

##Alternative Implementation There is an alternative implementation that allows one to send parameters from the calling grunt file to all the includes.

module.exports = function(grunt) {

	var config = require('grunt-split')(grunt,{
		files:[
			'grunt/bootstrap.conf.js',
		//	'grunt/angular.conf.js',
			'grunt/font-awesome.conf.js',
		]
	},parameters);
	
	grunt.initConfig(config);
	grunt.registerTask('default',[]);
};

grunt/bootstrap.conf.js

module.exports = function(parameters){
	var config={
		npm_tasks:[
			'grunt-contrib-concat',
			'grunt-contrib-watch',
			'grunt-contrib-less'
		],
		config:{
			less:{
				bootstrap:{
					//bootstrap less compilation configuration goes here
					//use parameters here
				}
			},
			concat:{
				bootstrap:{
					//concatenate any css and javascript here
				}
			},
			watch:{
				bootstrap:{
					//instructions on what to watch
				}
			}
		},
		aliasses:{
			'watch_all',['watch:bootstrap']
		}
	};

	return config;
}

##Merge Conflict Resolution It is useful knowing how the objects read from the different files get extended when a conflict is encountered

###Object Properties get overridden

// File 1
obj={
	key1:'value1'
}

// File 2
obj={
	key1:'value2',
	key2:'value2'
}

// Results In
obj={
	key1:'value2',
	key2:'value2'
}

###Object Properties get overridden unless they are objects, then they are extended

// File 1
obj={
	key1:{keyA:'value1'},
	key2:{keyA:'value1',keyB:'value2'}
}

// File 2
obj={
	key1:'value3',
	key2:{keyA:'value3',keyC:'value3'}
}

// Results In
obj={
	key1:'value3',
	key2:{keyA:'value3',keyB:'value2',keyC:'value3'}
}

###Array Properties get augmented

// File 1
obj={
	key1:['value1']
}

// File 2
obj={
	key1:['value2']
}

// Results In
obj={
	key1:['value1','value2'],
}