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 @
I have some trouble with the spawn function. I tried this example and the extended version from this docpad skeleton, but I get the same error every time:
I have the grunt-cli installed.
I use the following versions:
grunt - 0.4.1
bal-util - 2.1.0