Skip to content

Instantly share code, notes, and snippets.

@naganowl
Created July 3, 2014 02:17
Show Gist options
  • Save naganowl/8c0f761745cd656ed28e to your computer and use it in GitHub Desktop.
Save naganowl/8c0f761745cd656ed28e to your computer and use it in GitHub Desktop.
Notes on using grunt-cssshrink
  • Does some neat tricks like removing spaces, subbing equivalent values (transparent for rgba 0s), using single quotes, etc.
  • Didn't strip comments (at least I didn't find the option in Grunt plugin).
  • A bit weird that the example doesn't allow the file to be renamed.
  • Running it through cssmin first (to remove comments), didn't yield significant savings (< 1KB change)
  • Might be useful for really large CSS files.
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
concat:
# Stylus doesn't concat well with Bootstrap.
css:
src: [
'vendor/bower/bootstrap/dist/css/bootstrap.css'
'public/stylesheets/application.css'
]
dest: 'public/stylesheets/application.min.css'
cssmin:
compile:
options:
keepSpecialComments: 0
src: [
'vendor/bower/bootstrap/dist/css/bootstrap.css'
'public/stylesheets/application.css'
]
dest: 'public/stylesheets/application.min.css'
cssshrink:
compile:
files:
'public/stylesheets': [
'public/stylesheets/application.min.css'
]
grunt.registerTask 'build', [
'cssmin'
'cssshrink'
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment