grunt-contrib-compress icon indicating copy to clipboard operation
grunt-contrib-compress copied to clipboard

Rename function is ignored

Open llech opened this issue 7 years ago • 1 comments

I have a simple grunt build where I want to add files from main directory into zip, and additionally add minified javascript resurce from build directory. The config looks following:

module.exports = function(grunt) {

  grunt.initConfig({
	  uglify: {
      	target: {
      		files: {
      			'build/js/app.js': ['js/app.js']
			}
		}
	  },
	  compress: {
		main : {
			options: {
				archive: 'build/archive.zip',
				mode: 'zip'
			},
			files: [
				{ src: 'js/**' },
				{ src: 'build/js/**',
					rename: function(dest, src) {
                        grunt.log.writeln('rename')
						return dest + src.replace('build/js', 'js')
					}
				},
			]
		}
	  },  
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-compress');

  grunt.registerTask('dist', ['uglify','compress']);

};	  

I'm running grunt using npm. I refer version 1.4.1 of grunt-contrib-compress.

The problem is, that the rename function is silently ignored. The log message is not written, and the build/js files land under build/js in my zip, and not in js/ as I'd expect.

The documentation is vague, but it mentions using rename in examples in similar way, so I'd expect it to work. It does not, so I'm assuming it's a bug.

llech avatar Feb 08 '18 11:02 llech

I'm just trying to rename a single file when it is added to the archive, but that doesn't work either:

{ src: 'ebextensions', dest: '', rename: '.ebextensions' },

utdrmac avatar Feb 23 '18 22:02 utdrmac