Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  69] [ 4]  / answers: 1 / hits: 43134  / 11 Years ago, sat, january 11, 2014, 12:00:00

Here is my Gruntfile.js



module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON(package.json),

uglify: {
options: {
mangle: true
}
build: {
src: js/*.js,
dest: js/min/script.js
}
}

});

grunt.loadNpmTasks(grunt-contrib-uglify);

grunt.registerTask('default', [uglify]);

};





Here is my package.json - I have run npm install already, with all of the plugins that I will use in my Gruntfile, grunt-contrib-uglify is among them.



{
name: bootbuckle,
version: 0.1.0,
engines: {
node: >= 0.10.0
},
devDependencies: {
grunt: ~0.4.2,
grunt-contrib-watch: ~0.5.3,
grunt-contrib-sass: ~0.6.0,
grunt-csscomb: ~2.0.1,
grunt-contrib-htmlmin: ~0.1.3,
grunt-contrib-imagemin: ~0.4.1,
grunt-contrib-uglify: ~0.2.7
}
}





When I simply run grunt in the terminal - here is the error



  build: {
^^^^^
Loading Gruntfile.js tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task default not found. Use --force to continue.
Aborted due to warnings.


Thanks in advance for any help you may be able to provide.






EDIT
Following Matti's guidance I have inserted a missing comma, a new error is now being thrown



Loading Gruntfile.js tasks...ERROR
>> ReferenceError: uglify is not defined
Warning: Task default not found. Use --force to continue.
Aborted due to warnings.

More From » gruntjs

 Answers
2

You missed a comma here:



    uglify: {
options: {
mangle: true
}, // <-------
build: {
src: js/*.js,
dest: js/min/script.js
}
}


Edit: as posted by japrescott, you have to define uglify task as string.



grunt.registerTask('default', [uglify]);

[#73242] Friday, January 10, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jelani

Total Points: 473
Total Questions: 99
Total Answers: 99

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;