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 am unable to get this to work so far. I get the following error:
Do I need to install something, or as is suggested here call
loadNpmTasks
?