0.4.0 • Published 9 years ago

grunt-merge-media v0.4.0

Weekly downloads
51
License
-
Repository
github
Last release
9 years ago

grunt-merge-media

Merges duplicate media queries into one rule, appended to the bottom of your stylesheet. This allows you to write your media queries "inline" but still combine them into one rule to avoid code duplication.

Getting Started

This plugin requires Grunt ~0.4.5

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-merge-media --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-merge-media');

The "merge_media" task

Overview

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

grunt.initConfig({
	merge_media: {
		options: {
			// Task-specific options go here.
		},
		your_target: {
			// Target-specific file lists and/or options go here.
		},
	},
});

Options

options.compress

Type: Boolean Default value: false

A Boolean value that will switch the compression of the processed file. This is passed straight into the stringify method in css.

options.logFile

Type: Boolean Default value: false

When set to true, a log file with details of the merge will be created in the working directory.

Usage Examples

grunt.initConfig({
	merge_media: {
		options: {
			compress: true,
			logFile: true
		},
		files: {
			'styles/css': ['styles/base.css', 'styles/layout/*.css'],
		},
	}
});

If the file destination is a folder, the stylesheet will be created in that folder with the same name as the original. Otherwise, it will be created in the exact path specified.

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

  • 2014-11-21 v0.4.0 Adds support for nested media queries
  • 2014-11-21 v0.3.0 Adds log file
  • 2014-11-21 v0.2.3 Initial release
0.4.0

9 years ago

0.3.0

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago