The following will minify your assets with grunt each time a generation write completes.
-
Install Dependencies
npm install grunt safeps --save npm install grunt-cli -g
-
Create your website's grunt file to specify what we should minify. Guide here.
-
Add the following to your docpad configuration file
events: # Write After # Used to minify our assets with grunt writeAfter: (opts,next) -> # Prepare safeps = require('safeps') pathUtil = require('path') docpad = @docpad rootPath = docpad.getConfig().rootPath gruntPath = pathUtil.join(rootPath, 'node_modules', '.bin', 'grunt') # Perform the grunt `min` task # https://github.com/gruntjs/grunt/blob/0.3-stable/docs/task_min.md command = [gruntPath, 'min'] # Execute safeps.spawn(command, {cwd:rootPath,output:true}, next) # Chain @
In windows you need to make sure the Grunt command line is installed with
I then had to change the command value in the docpad.coffee file to: