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-feature

v0.3.0

Published

A grunt task which generates feature configuration files to support code being released early and often and to synchronise features between JavaScript & CSS.

Downloads

4

Readme

grunt-feature build status

A grunt task which can be used to generate feature configuration files to support code being released early and often and to synchronise features between JavaScript & CSS.

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide.

From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:

npm install grunt-feature --save-dev

Once that's done, add this line to your project's Gruntfile:

grunt.loadNpmTasks('grunt-feature'); 

If the plugin has been installed correctly, running grunt --help at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a devDependency, which ensures that it will be installed whenever the npm install command is run.

The "feature" task

grunt-feature will generate a configuration file which can be consumed by other tasks.

For example if you are using require.js with pragmas or similar, the task can be used to control which features are to be included as part of an r.js optimizer build.

Equally a configuration file can be generated to introduce feature toggling as part of a CSS pre-processor build.

The real power is when you combine the two. If you no-longer need a feature, or a feature is to be only used by a subset of sites the task can be used to omit both the JavaScript and CSS for a given feature.

Defining a feature

Features are managed via json configuration files which are used to describe what a feature does and more importantly whether it should be enabled.

If multiple configuration files are passed, these are deeply merged together with the resulting conguration file a combination of all options, either added or overriden.

When managing multiple web-sites which share a common code base and build process, this provides scope to turn off common features and manage those which are localised.

When defining features the resulting generated file will be namespaced based upon the source json object processed.

feature.json

{
	"feature-1": true,
	"feature-2": false,

	"feature-3": {

		"description": "Vehicula Euismod Cras Ornare Fringilla",
		"value": true

	},

	"feature-4": {

		"a": true,
		"b": false,

		"c": {

			"description": "Vehicula Euismod Cras Ornare Fringilla",
			"value": true,

			"children": {

				"a": false

			}

		}

	}

}

Defining a feature in feature.json

_feature.scss

$feature-1: true !default
$feature-2: false !default
$feature-3: true !default // Vehicula Euismod Cras Ornare Fringilla
$feature-4-a: true !default
$feature-4-b: false !default
$feature-4-c: true !default // Vehicula Euismod Cras Ornare Fringilla
$feature-4-c-d: false !default

Templates

Handlebar templates can be used to control what the output should look like for a generated configuration file.

{{#features}}
	${{name}}: {{value}} !default; //{{description}}
{{/features}

SCSS template example

The default template to use will be automatically determined based upon the destination file extension unless an override is explicitly provided as an option. In addition to this a template path can also be specified should the need arise to define one.

grunt-feature comes bundled with templates for JavaScript, JSON and SCSS/Less by default.

Overview

In your project's Gruntfile, add a section named feature to the data object passed into grunt.initConfig().

grunt.initConfig({

  feature: {

    options: {

      // global options

      toggles: {
      		// some global toggles
      }

    },

    your_target: {

    	options: {

    		// task options,

    		toggles: {

    			// some target toggles

    		}

    	},

	    files: {
	        'some/path/to/config.scss': ['framework/config.json', 'site/config.json']
			'some/path/to/config.json': ['framework/config.json', 'site/config.json']
	    }

    }

  }

})

Release History

  • 21/10/2013 0.1.0 | Intial release