Created
November 7, 2013 14:09
-
-
Save toranb/7355103 to your computer and use it in GitHub Desktop.
basic grunt file for ember.js including a dev and deploy task
This file contains 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
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