I am writing a Gruntjs script that should
- concatenate + replace the template of some JS files in the target directory (contrib-concat)
- copies + replaces the template of some other files (contrib-copy)
- pack files into a zip file
contrib-concat has a logical process option for replacing templates (for example, <% pkg.version %> ) when processing files.
Contrib-copy also has a processContent option, however I do not know how to invoke template processing with this option.
module.exports = function(grunt) { grunt.initConfig({ meta: { banner: ' \ /*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n \ * <%= pkg.homepage %>\n \ */\n\n', build_date: '<%= grunt.template.today("yyyy-mm-dd") %>', build_num: process.env.BUILD_NUMBER || 0, // Jenkins build number if available version_string: '<%= pkg.version %>-<%= meta.build_num %>', dist_dir: 'dist/<%= pkg.version %>' }, pkg: grunt.file.readJSON('package.json'), concat: { options: { stripBanners: { block: true }, process: true, separator: '\n /* ----- */ \n', banner: '<%= meta.banner %>' }, dist: { src: [ 'src/ViewUtility.js', 'src/ViewClass.js', 'src/ViewClass.js', 'src/MarksClass.js', 'src/ViewVersion.js'], dest: 'build/View.js' } }, uglify: { options: { mangle: { except: ['jQuery', 'Hammer'] }, banner: '<%= meta.banner %>' }, dist: { src: '<%= pkg.main %>', dest: 'build/View.min.js' } }, copy: { options: { processContent: true }, dist: { files: [ {expand: true, cwd: 'build/', src: ['**'], dest: '<%= meta.dist_dir %>/view/'}, {expand: true, cwd: 'src/', src: ['View-tp.js'], dest: '<%= meta.dist_dir %>/view/'}, {expand: true, cwd: 'src/', src: ['plugin.json'], dest: '<%= meta.dist_dir %>/'} ] } }, compress: { dist: { options: { archive: 'view_' + '<%= meta.version_string %>_<%= meta.build_date %>' + '.zip' }, expand: true, cwd: 'dist/', src: ['**/*'] } } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-compress'); grunt.registerTask('default', ['concat', 'uglify', 'copy', 'compress']); };
processContent above does not work. Please suggest solutions.