|
module.exports = function(grunt) { |
|
// -- LOAD GRUNT PLUGINS -- // |
|
grunt.loadNpmTasks('grunt-contrib-clean'); |
|
grunt.loadNpmTasks('grunt-contrib-copy'); |
|
grunt.loadNpmTasks('grunt-contrib-concat'); |
|
|
|
grunt.registerMultiTask('debug_files', 'debugs files passed in', |
|
function() { |
|
grunt.log.writeln('Inside task: ' + this.nameArgs); |
|
try { |
|
var files = this.filesSrc; |
|
grunt.log.writeln('files: ' + files); |
|
} |
|
catch(ex) { |
|
grunt.log.writeln('no files exception'); |
|
} |
|
} |
|
); |
|
|
|
debugger; |
|
|
|
var src_files = ['a.js', 'b.js'], |
|
build_dir = 'build'; |
|
|
|
// --- CREATE CONFIGURATION --- // |
|
var config = { |
|
pkg: grunt.file.readJSON('package.json'), |
|
|
|
// Clean up the build area |
|
clean: { |
|
options: { |
|
force: true |
|
}, |
|
full : [build_dir] |
|
}, |
|
|
|
copy: { |
|
dev: { |
|
files: [ |
|
{ dest: 'build/', src: src_files } |
|
] |
|
}, |
|
prod: { |
|
src: src_files, |
|
dest: 'build/prod/' |
|
} |
|
}, |
|
|
|
concat: { |
|
prod: { |
|
files: [ |
|
{ dest: 'build/prod.js', src: src_files } |
|
] |
|
}, |
|
dev: { |
|
src: src_files, |
|
dest: 'build/dev.js' |
|
} |
|
}, |
|
|
|
// Write out the dest values from the items above. |
|
// I would expect that all of these would print out valid files, |
|
// but the ones that use the files array format don't seem to work. |
|
debug_files: { |
|
concat_prod_files: { |
|
src: ['<%= concat.prod.dest %>'] |
|
}, |
|
concat_dev_files: { |
|
src: ['<%= concat.dev.dest %>'] |
|
}, |
|
copy_dev_files: { |
|
src: ['<%= copy.dev.dest %>'] |
|
}, |
|
copy_prod_files: { |
|
src: ['<%= copy.prod.dest %>'] |
|
} |
|
} |
|
}; |
|
|
|
// Register config and aliases |
|
grunt.initConfig(config); |
|
grunt.registerTask('default', ['clean', 'copy', 'concat', 'debug_files']); |
|
}; |