Skip to content

Instantly share code, notes, and snippets.

@ElliotChong
Created November 14, 2013 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElliotChong/7470678 to your computer and use it in GitHub Desktop.
Save ElliotChong/7470678 to your computer and use it in GitHub Desktop.
Example Gruntfile showing concurrent CoffeeScript > JS > minification, SASS > CSS > minification, livereload, and nodemon / nodeinspector tandem.
module.exports = (grunt) ->
config =
browserify:
development:
options:
transform: ["coffeeify"]
debug: true
files:
"./public/scripts/editor.js": ["./frontend/scripts/editor.coffee"]
uglify:
production:
expand: true
src: ["./public/**/*.js", "!./public/**/*.min.js", "!./public/**/jquery*.js"]
ext: ".min.js"
sass:
development:
options:
sourcemap: true
trace: true
style: "expanded"
files:
"./public/styles/main.css": "./frontend/sass/main.scss"
production:
options:
sourcemap: false
trace: false
style: "compressed"
files:
"./public/styles/main.min.css": "./frontend/sass/main.scss"
# csscss:
# development:
# src: ["./public/**/*.min.css"]
cssmin:
production:
# options:
# report: "gzip"
expand: true
src: ["./public/**/*.css", "!./public/**/*.min.css"]
ext: ".min.css"
csso:
production:
# options:
# report: "gzip"
expand: true
src: ["./public/**/*.css", "!./public/**/*.min.css"]
ext: ".o.min.css"
nodemon:
web:
options:
file: "web.coffee"
env:
NODE_ENV: "development"
debug:
options:
file: "web.coffee"
nodeArgs: ["--debug"]
env:
NODE_ENV: "development"
production:
options:
file: "web.coffee"
env:
NODE_ENV: "production"
"node-inspector":
development: {}
watch:
scripts:
options:
atBegin: true
spawn: true
files: ["./frontend/scripts/**/*.coffee", "./frontend/scripts/**/*.js", "./shared/src/**/*.coffee", "./shared/src/**/*.js"]
tasks: ["browserify:development", "uglify:production"]
styles:
options:
atBegin: true
spawn: true
files: ["./frontend/sass/**/*.scss"]
tasks: ["sass:development", "sass:production", "concurrent:cssmin"]
livereload:
options:
livereload: true
spawn: true
files: ["./frontend/**/*.ractive", "./shared/**/*.ractive", "./public/**/*", "!./public/**/*.min.js", "!./public/**/*.min.css"]
concurrent:
cssmin:
tasks: ["cssmin:production", "csso:production"]
options:
logConcurrentOutput: true
process:
tasks: ["watch:styles", "watch:scripts"]
options:
logConcurrentOutput: true
web:
tasks: ["nodemon:web", "watch:livereload"]
options:
logConcurrentOutput: true
debug:
tasks: ["node-inspector", "nodemon:debug", "watch:livereload"]
options:
logConcurrentOutput: true
all:
tasks: ["concurrent:process", "concurrent:web"]
options:
logConcurrentOutput: true
grunt.initConfig config
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-concurrent"
grunt.loadNpmTasks "grunt-node-inspector"
grunt.loadNpmTasks "grunt-nodemon"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-browserify"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-sass"
grunt.loadNpmTasks "grunt-csscss"
grunt.loadNpmTasks "grunt-contrib-cssmin"
grunt.loadNpmTasks "grunt-csso"
grunt.registerTask "default", "User options", ->
grunt.log.writeln """
Grunt Commands:
grunt all
grunt concurrent:process
grunt concurrent:web
grunt process
grunt watch:scripts
grunt watch:styles
grunt web
grunt nodemon:web
grunt watch:livereload
grunt debug
grunt node-inspector
grunt nodemon:debug
grunt watch:livereload
"""
grunt.registerTask "debug", ["concurrent:debug"]
grunt.registerTask "web", ["concurrent:web"]
grunt.registerTask "process", ["concurrent:process"]
grunt.registerTask "all", ["concurrent:all"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment