Getting Started with Grunt for Better Frontend Ops: DrupalCon Austin Session Notes
Wayne Eaker
Why use Grunt
- Grunt is for automated front-end workflows.
- Allows automation of best practices.
- Work in small chunks of code.
- Test and lint our code
- Abstract front-end code with SASS
Steps
- Install Node.js (brew install node)
- Package.json: like module.info (npm init)
- Install Grunt (npm install grunt-cli -g)
- Install Grunt plugins.
- npm install --save-dev grunt
- Gruntfile.js
- Configure tasks
- Install SASS Task npm install --save-dev grunt-contrib-sass
- Default Task (compile SASS, etc)
Tasks / Plugins
- Autoprefixer: adds vendor prefixes automatically
- http://gruntjs.com/plugins
- Watch task: automatically runs grunt for you when files change.
- Live Reload
- CSSmin
- JShint
- browserify
- uglifyjs
- PHP Codesniffer
- PHP Lint
- PHP Unit
- Drush: call drush commands automatically
- load-grunt-config - config with YAML
- grunt-notify: notifications to growl or notification center on fails
- grunt-newer: only run certain tasks on new files
What about Gulp?
- Faster build times
- Pipes directly between tasks with less temp files.