Reputation: 18939
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?
Upvotes: 1
Views: 542
Reputation: 48566
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'
}
}
});
Upvotes: 2