Skip to content

Instantly share code, notes, and snippets.

@toranb
Created November 7, 2013 14:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toranb/7355103 to your computer and use it in GitHub Desktop.
Save toranb/7355103 to your computer and use it in GitHub Desktop.
basic grunt file for ember.js including a dev and deploy task
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-ember-template-compiler');
grunt.loadNpmTasks('grunt-hashres');
grunt.initConfig({
watch: {
scripts: {
files: ['foo/static/something_ui/js/app/*.js', 'foo/static/something_ui/templates/*.handlebars'],
tasks: ['dev'],
options: {
interrupt: true,
debounceDelay: 250
}
}
},
hashres: {
options: {
renameFiles: true
},
prod: {
src: ['foo/static/something_ui/js/dist/deps.min.js'],
dest: 'foo/templates/something_ui/index.html'
}
},
concat: {
dist: {
src: [
'foo/static/something_ui/js/lib/jquery-1.9.1.js',
'foo/static/something_ui/js/lib/handlebars-1.0.0.js',
'foo/static/something_ui/js/lib/ember-1.0.0-prod.js',
'foo/static/something_ui/js/app/*.js',
'foo/static/something_ui/js/dist/tmpl.min.js'],
dest: 'foo/static/something_ui/js/dist/deps.min.js'
}
},
emberhandlebars: {
compile: {
options: {
templateName: function(sourceFile) {
var newSource = sourceFile.replace('foo/static/something_ui/templates/', '');
return newSource.replace('.handlebars', '');
}
},
files: ['foo/static/something_ui/templates/*.handlebars'],
dest: 'foo/static/something_ui/js/dist/tmpl.min.js'
}
}
});
grunt.task.registerTask('dev', ['coffee', 'emberhandlebars', 'concat:dist']);
grunt.task.registerTask('local', ['dev', 'watch']);
grunt.task.registerTask('deploy', ['coffee', 'emberhandlebars', 'concat:dist', 'hashres']);
};
//note your index.html file should then look like this
//<body>
// <script type="text/javascript" src="static/something_ui/js/dist/deps.min.js"></script>
//</body>
//</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment