Skip to content

Instantly share code, notes, and snippets.

@invmatt
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save invmatt/9090154 to your computer and use it in GitHub Desktop.

Select an option

Save invmatt/9090154 to your computer and use it in GitHub Desktop.
Concatinates sass (using compass) and outputs production (minified) and dev (expanded) files, lints the production CSS and smushes images.
/**
* Default Grunt File
* @version 0.1.0
* @description Concatinates sass and outputs production and dev, lints the production CSS, smushes images
*/
module.exports = function(grunt) {
grunt.initConfig({
/**
* PROJECT CONFIGURATION
* @description Sets the default paths and banner (taken from package.json)
* @usage <%= files.TYPE %>
*/
pkg: grunt.file.readJSON('package.json'),
files: {
grunt: ['gruntfile.js'],
js: ['js/*.js'],
sass: ['sass/*.scss'],
img: ['images']
},
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | ' +
'<%= grunt.template.today("dd-mm-yyyy-hh:MM:ss") %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> |' +
' Licensed <%= pkg.license %>\n */\n',
/**
* CSS
* @requires Compass
* @description Concatinates for dev (with sourcemaps) and concatinates + minifies for production
*/
compass: {
dev: {
options: {
sassDir: 'sass',
cssDir: 'css/dev',
outputStyle: 'expanded'
}
},
dist: {
options: {
sassDir: 'sass',
cssDir: 'css/production',
environment: 'production',
outputStyle: 'compressed'
}
}
},
// Lint production CSS
csslint: {
styles: {
src: ['css/production/*.css'],
options: {
"important": false,
"adjoining-classes": false,
"known-properties": false,
"box-sizing": false,
"box-model": false,
"overqualified-elements": false,
"display-property-grouping": false,
"bulletproof-font-face": false,
"compatible-vendor-prefixes": false,
"regex-selectors": false,
"errors": true,
"duplicate-background-images": false,
"duplicate-properties": false,
"empty-rules": false,
"selector-max-approaching": false,
"gradients": false,
"fallback-colors": false,
"font-sizes": false,
"font-faces": false,
"floats": false,
"star-property-hack": false,
"outline-none": false,
"import": false,
"ids": false,
"underscore-property-hack": false,
"rules-count": false,
"qualified-headings": false,
"selector-max": false,
"shorthand": false,
"text-indent": false,
"unique-headings": false,
"universal-selector": false,
"unqualified-attributes": false,
"vendor-prefix": false,
"zero-units": false
}
}
},
/**
* IMAGE COMPRESS
*/
smushit: {
path: { src: '<%= files.img %>' }
},
/**
* WATCH
*/
watch: {
files: ['<%= files.grunt %>', 'sass/*.scss', '<%= files.img %>'],
tasks: ['default']
}
});
/**
* LOAD TASKS
*/
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-smushit');
/**
* REGISTER TASKS
*/
grunt.registerTask('default', ['compass', 'csslint', 'smushit']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment