Skip to content

Instantly share code, notes, and snippets.

@Hoverbear
Created August 28, 2013 18:06
Show Gist options
  • Save Hoverbear/6369227 to your computer and use it in GitHub Desktop.
Save Hoverbear/6369227 to your computer and use it in GitHub Desktop.
Gruntfile template
module.exports = (grunt) ->
# Package configuration.
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
coffee:
options:
join: true
bare: true
files:
src: "src/**/*.coffee"
dest: 'src/scripts.js'
uglify:
coffee:
options:
mangle: false
src: 'src/scripts.js'
dest: 'build/scripts.min.js'
vendor:
options:
mangle: false
src: ['src/vendor/**/*.js', '!src/vendor/**/*.min.js']
dest: 'build/vendor/vendor.js'
cssmin:
files:
src: ['src/**/*.css', '!src/**/*.min.css']
dest: 'build/styles.min.css'
concat:
scripts:
options:
banner: '/*! <%= pkg.name %>, Built on <%= grunt.template.today("yyyy-mm-dd") %> */\n'
files:
'build/scripts.min.js': ['build/vendor/vendor.js', 'src/vendor/**/*.min.js', 'build/scripts.min.js']
styles:
options:
banner: '/* <%= pkg.name %>, Built on <%= grunt.template.today("yyyy-mm-dd") %> */\n'
files:
'build/styles.min.css': ['build/styles.min.css', 'src/vendor/**/*.min.css']
copy:
html:
expand: true
cwd: 'src'
src: '**/*.html'
dest: 'build/'
fonts:
expand: true
flatten: true
cwd: 'src'
src: '**/*.woff'
dest: 'build/fonts'
clean:
pre:
src: ['build']
post:
src: ['src/scripts.js', 'src/vendor/vendor.js']
watch:
options:
livereload: true
coffee:
files: 'src/**/*.coffee'
tasks: ['coffee', 'uglify:coffee', "concat:scripts", "clean:post"]
html:
files: 'src/**/*.html'
tasks: ['copy:html']
css:
files: 'src/**/*.css'
tasks: ['cssmin', 'concat:styles', 'clean:post']
connect:
build:
options:
port: 8080
base: 'build'
# Load Plugins
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.registerTask 'build', ['clean:pre', 'coffee', 'uglify', 'cssmin', 'concat', 'copy', 'clean:post']
grunt.registerTask 'dev', ['build', 'connect', 'watch']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment