1

I'm trying to configure two uglify targets:

module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { development: { options: { banner: '// DEVELOPMENT\n', report: 'gzip' }, build: { src: 'js/**/*.js', dest: 'dist/<%= pkg.name %>.min.js' } }, production: { options: { banner: '// PRODUCTION\n' }, build: { src: 'js/**/*.js', dest: 'dist/<%= pkg.name %>.min.js' } } } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['uglify:production']); }; 

Neither uglify:development nor uglify:production produces any output nor errors.

The task runs fine if I don't use any targets (just adding options and build directory to uglify object).

Is there anything else I'm missing?

1 Answer 1

2

The reason why it's not working is that you must've copied it from somewhere, and assumed that build was part of a target, when in reality the options applied to every target, and build was a target.

options can be either target-specific or apply to every target.

Try it like this:

 grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { development: { options: { banner: '// DEVELOPMENT\n', report: 'gzip' }, src: 'js/**/*.js', dest: 'dist/<%= pkg.name %>.min.js' }, production: { options: { banner: '// PRODUCTION\n' }, src: 'js/**/*.js', dest: 'dist/<%= pkg.name %>.min.js' } } }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.