Created
July 3, 2012 22:02
-
-
Save inf0rmer/3043675 to your computer and use it in GitHub Desktop.
Sample Grunt JS configuration file by steve8708
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My current grunt.js file, includes examples for compiling less, | |
// handlebars templates, file watching, etc | |
// | |
// My most used task is the "watch-serve" task for linting/testing | |
// my files as I work, has been amazingly helpful | |
// | |
// This is a custom modification of @tbranyen's fantastic | |
// boilerplate-handlebars-layoutmanager project gruntfile | |
// | |
// NOTE: for this to work you need to install the below npm tasks | |
// (e.g. grunt-handlebars) at the same level as your grunt.js file | |
// for the grunt.loadNpmTasks() to work | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
clean: { | |
folder: "dist/debug/*" | |
}, | |
lint: { | |
files: [ | |
"app/**/*.js" | |
] | |
}, | |
jshint: { | |
options: { | |
curly: true, | |
eqeqeq: true, | |
immed: true, | |
latedef: true, | |
noarg: true, | |
sub: true, | |
boss: true, | |
eqnull: true, | |
browser: true, | |
scripturl: true | |
}, | |
globals: { | |
jQuery: true | |
} | |
}, | |
jst: { | |
"dist/debug/templates.js": [ | |
"app/templates/**/*.html" | |
] | |
}, | |
handlebars: { | |
all: { | |
src: 'app/templates', | |
dest: "dist/debug/templates.js" | |
} | |
}, | |
concat: { | |
"dist/debug/require.js": [ | |
"assets/js/libs/almond.js", | |
"dist/debug/templates.js", | |
"dist/debug/require.js" | |
] | |
}, | |
cssmin: { | |
"dist/release/index.css": [ | |
"assets/css/style.css", | |
"dist/debug/less.css" | |
] | |
}, | |
min: { | |
"dist/release/require.js": [ | |
"dist/debug/require.js" | |
] | |
}, | |
server: { | |
port: 8888, | |
debug: { | |
port: 8888, | |
folders: { | |
"app": "dist/debug", | |
"app/templates": "app/templates", | |
"assets/js/libs": "dist/debug" | |
} | |
}, | |
release: { | |
port: 8888, | |
folders: { | |
"app": "dist/release", | |
"app/templates": "app/templates", | |
"assets/js/libs": "dist/release", | |
"assets/css": "dist/release" | |
} | |
} | |
}, | |
watch: { | |
files: ['<config:lint.files>', 'app/**/*.less', 'app/**/*.handlebars'], | |
tasks: 'lint less qunit handlebars' | |
}, | |
less: { | |
all: { | |
src: 'app/less/main.less', | |
dest: 'dist/debug/less.css' | |
} | |
}, | |
requirejs: { | |
mainConfigFile: "app/config.js", | |
out: "dist/debug/require.js", | |
name: "config", | |
wrap: false | |
}, | |
qunit: { | |
all: ["test/qunit/*.html"] | |
} | |
}); | |
grunt.loadNpmTasks('grunt-clean'); | |
grunt.loadNpmTasks('grunt-handlebars'); | |
grunt.loadNpmTasks('grunt-requirejs'); | |
grunt.loadNpmTasks('grunt-less'); | |
grunt.loadNpmTasks('grunt-css'); | |
grunt.registerTask("default", "clean lint less handlebars qunit requirejs concat"); | |
grunt.registerTask("debug", "default"); | |
grunt.registerTask("watch-serve", "server watch"); | |
grunt.registerTask("test", "default qunit"); | |
grunt.registerTask("release", "default min cssmin"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment