You can use concat
to do that.
For example, in your Gruntfile.js
:
module.exports = function(grunt) {
return grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// EDIT: TO COMPILE YOUR COFFEESCRIPT
coffee: {
"default": {
src: paths.coffee_src,
dest: paths.js_dir,
options: {
preserve_dirs: true,
base_path: paths.coffee_dir
}
}
},
concat: {
options: {
separator: ';'
},
dist: {
src: ['assets/javascripts/libs/underscore/underscore.js', 'assets/javascripts/libs/jquery/jquery.js', 'assets/javascripts/libs/json2/json2.js', 'assets/javascripts/libs/handlebars-wycats/dist/handlebars.js', 'assets/javascripts/libs/backbone/backbone.js', 'assets/javascripts/libs/marionette/lib/backbone.marionette.js', 'assets/javascripts/*.js', 'assets/javascripts/utilities/*.js', 'assets/javascripts/models/*.js', 'assets/javascripts/collections/*.js', 'assets/javascripts/modules/**/**/*.js'],
dest: '<%= pkg.name %>.js'
}
},
// ...
// EDIT: TO MINIFY YOUR CONCATENATED JS
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
// ...
Here I'm concatenating all files in that order (starting with underscore.js), so, you'll have a single js file with all those files, in the specific order that you desire.
Check this documentation for more information.