Skip to content

Instantly share code, notes, and snippets.

@HoundstoothSTL
Forked from balupton/README.md
Created May 20, 2013 23:52
Show Gist options
  • Save HoundstoothSTL/5616543 to your computer and use it in GitHub Desktop.
Save HoundstoothSTL/5616543 to your computer and use it in GitHub Desktop.

DocPad: Minify your assets with Grunt

The following will minify your assets with grunt each time a generation write completes.

Installation

  1. Install Dependencies

    npm install --save grunt bal-util
  2. Create your website's grunt file to specify what we should minify. Guide here.

  3. Add the following to your docpad configuration file

    # Write After
    # Used to minify our assets with grunt
    writeAfter: (opts,next) ->
    	# Prepare
    	balUtil = require('bal-util')
    	docpad = @docpad
    	rootPath = docpad.config.rootPath
    
    	# Perform the grunt `min` task
    	# https://github.com/gruntjs/grunt/blob/0.3-stable/docs/task_min.md
    	command = ["#{rootPath}/node_modules/.bin/grunt", 'min']
    	
    	# Execute
    	balUtil.spawn(command, {cwd:rootPath,output:true}, next)
    
    	# Chain
    	@

Working Example

Check out Luke Arrys's HTML5 Boilerplate + Grunt Skeleton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment