• Stars
    star
    119
  • Rank 297,158 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This grunt plugin is deprecated!

grunt-css

Grunt plugin for linting and minifying CSS

Note: This plugin is deprecated and won't be updated anymore. For the cssmin task, use grunt-contrib-cssmin instead, for csslint, use grunt-contrib-csslint.

Getting Started

Install the module with:

npm install grunt-css --save-dev

Then load it from your own Gruntfile.js file:

grunt.loadNpmTasks('grunt-css');

grunt 0.3 compability

If you're using grunt 0.3, install the 0.1.0 version of this task:

npm install [email protected]

Documentation

This plugin provides two tasks: cssmin and csslint. Both area multi tasks, meaning that grunt will automatically iterate over all cssmin and csslint targets if a target is not specified.

cssmin

This works similar to the uglify task. Specify a src and dest property for input and output:

// Project configuration.
grunt.initConfig({
	cssmin: {
		my_target: {
			src: 'src/input.css',
			dest: 'dist/output.min.css'
		}
	}
});

Exposes option of clean-css, which you can set per target or for all, as usual: keepSpecialComments

// Project configuration.
grunt.initConfig({
	cssmin: {
		options: {
			keepSpecialComments: 0
		},
		my_target: {
			options: {
				keepSpecialComments: 1
			},
			src: 'src/input.css',
			dest: 'dist/output.min.css'
		}
	}
});

Banner comments

In this example, running grunt cssmin:my_target will prepend a banner created by interpolating the banner template string with the config object. Here, those properties are the values imported from the package.json file (which are available via the pkg config property) plus today's date.

// Project configuration.
grunt.initConfig({
	pkg: grunt.file.readJSON('package.json'),
	cssmin: {
		options: {
			banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
				'<%= grunt.template.today("yyyy-mm-dd") %> */'
		},
		my_target: {
			files: {
				src: 'src/input.css',
				dest: 'dist/output.min.css'
			}
		}
	}
});

csslint

This is similar to the built-in lint task, though the configuration is different. Here's an example:

csslint: {
	base_theme: {
		src: "themes/base/*.css",
		rules: {
			"import": false,
			"overqualified-elements": 2
		}
	}
}

src specifies the files to lint, rules the rules to apply. A value of false ignores the rule, a value of 2 will set it to become an error. Otherwise all rules are considered warnings.

For the current csslint version, these rules are available:

important
adjoining-classes
known-properties
box-sizing
box-model
overqualified-elements
display-property-grouping
bulletproof-font-face
compatible-vendor-prefixes
regex-selectors
errors
duplicate-background-images
duplicate-properties
empty-rules
selector-max-approaching
gradients
fallback-colors
font-sizes
font-faces
floats
star-property-hack
outline-none
import
ids
underscore-property-hack
rules-count
qualified-headings
selector-max
shorthand
text-indent
unique-headings
universal-selector
unqualified-attributes
vendor-prefix
zero-units

For an explanation of those rules, check the csslint wiki.

Side note: To update this list, run this:

node -e "require('csslint').CSSLint.getRules().forEach(function(x) { console.log(x.id) })"

Contributing

Please use the issue tracker and pull requests.

License

Copyright (c) 2012 JΓΆrn Zaefferer Licensed under the MIT license.

More Repositories

1

jquery-treeview

A jQuery Tree plugin
HTML
633
star
2

undo

Undo.js
JavaScript
311
star
3

jquery-prettydate

jQuery plugin for "x ago" date formatting with auto update
JavaScript
96
star
4

commitplease

Validates strings as commit messages
JavaScript
87
star
5

simple-history

A simple JavaScript HTML5 history library
JavaScript
50
star
6

webpack-jquery-ui

How to build an app with jQuery UI and webpack
JavaScript
47
star
7

node-testswarm

Nodejs module for interacting with TestSwarm
JavaScript
18
star
8

grunt-esformatter

Grunt wrapper plugin for esformatter - validate or format your JavaScript code
JavaScript
16
star
9

pitfalls-examples

JavaScript
14
star
10

jquery-validation.password

JavaScript
13
star
11

grunt-check-modules

Grunt plugin for checking that all node_modules are installed and up-to-date.
JavaScript
13
star
12

node-experiments

JavaScript
8
star
13

flocking

JavaScript
8
star
14

webaudio

Experiments with audio on the web
JavaScript
7
star
15

effective-jquery

CSS
7
star
16

talk-to-me

JavaScript
6
star
17

contenteditable

A different approach to a richtext editor.
JavaScript
6
star
18

jquery-web-rhino

jQuery-based web framework, running on Rhino
JavaScript
5
star
19

video-call-linter

JavaScript
5
star
20

sadtrombone2

Building an (eventually) html5-powered sadtrombone.com clone
JavaScript
4
star
21

iframe-remoting

Remote control of connected browser clients.
PHP
4
star
22

esformatter-jquery-chain

Esformatter plugin for formatting member expressions according to the jQuery style guide
JavaScript
3
star
23

jquery-ui-videoplayer

Hosts a composite demo for jQuery UI
3
star
24

slides-docker-for-js-devs

CSS
3
star
25

web-rocketbook-theme

PHP
3
star
26

historytest

An interactive test for the HTML5 history API, with focus on the addressbar updating properly - something too many implementions still get wrong.
JavaScript
3
star
27

jquery-docs

Moved to jquery account
2
star
28

web-rocketsquared-theme

PHP
2
star
29

Matchup

JavaScript
1
star
30

tweet-id

railslove challenge in nodejs
JavaScript
1
star
31

keyword-slicer

JavaScript
1
star
32

standards-tracker

A public issue tracker for standards issues I'm involved in
1
star
33

browserify-jquery-ui

JavaScript
1
star
34

button-lite

A button widget optimized for lots of push-buttons, using the jQuery UI CSS framework and button css
JavaScript
1
star
35

tdd-widgetfactory

JavaScript
1
star
36

sifrp-generator

A generator for tertiary NSCs for the Song of Ice and Fire Role Playing Game (SIFRP)
JavaScript
1
star
37

jglove2011

Java
1
star
38

scalagaming

Some experiments in game programming, with Java/Scala/Swing
Scala
1
star
39

bassistance-plugins

Automatically exported from code.google.com/p/bassistance-plugins
JavaScript
1
star
40

web-bassistance-theme

PHP
1
star
41

wiihomejs

JavaScript
1
star
42

game-of-qr

https://bassistance.de/2022/01/15/app-idea-game-of-qr/
JavaScript
1
star