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 @
Could anyone go into details about (2) please? I don't get what I have to do with the grunt file. I suppose it's the file which is in /node_modules/grunt/Gruntfile.js ? There's lots of stuff in there, so what do I have to add/adjust to minify my HTML, CSS and JS?
Sorry for the newbie question... Thanks a lot!