Skip to content

Instantly share code, notes, and snippets.

@bcherny
Created October 15, 2013 05:18
Show Gist options
  • Save bcherny/6986859 to your computer and use it in GitHub Desktop.
Save bcherny/6986859 to your computer and use it in GitHub Desktop.
Gruntfile for compiling and minifying dependency-free coffeescripts. Names the file after its current directory.
module.exports = (grunt) ->
nameParts = __dirname.split '/'
name = nameParts[nameParts.length - 1]
config =
pkg: 'package.json'
coffee:
compile:
files: {}
uglify:
options:
mangle:
toplevel: true
compress:
dead_code: true
unused: true
join_vars: true
comments: false
standard:
files: {}
# configure coffee, uglify
config.coffee.compile.files[name + '.js'] = name + '.coffee'
config.uglify.standard.files[name + '.min.js'] = [name + '.js']
# load config
grunt.config.init config
# load tasks
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-uglify'
# register tasks
grunt.registerTask 'default', ['coffee', 'uglify']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment