gruntjs - unexpected identifier error in grunt.js file -
can tell me why getting following error in terminal when running following grunt.js file?
module.exports = function(grunt) { grunt.initconfig({ pkg: grunt.file.readjson('package.json'), concat: { // here our concatenating dist: { src: [ 'components/js/*.js' // in src js folder ], dest: 'js/script.js', } } uglify: { build: { src: 'js/script.js', dest: 'js/script.min.js' } } }); //add plugins here grunt.loadnpmtasks('grunt-contrib-concat'); grunt.loadnpmtasks('grunt-contrib-uglify'); //what happens when type 'grunt' in terminal grunt.registertask('default', ['concat', 'uglify']); };
the error is:
loading "gruntfile.js" tasks...error
syntaxerror: unexpected identifier warning: task "default" not found. use --force continue.
thanks!
you have missing comma:
grunt.initconfig({ pkg: grunt.file.readjson('package.json'), concat: { dist: { src: [ 'components/js/*.js' ], dest: 'js/script.js', } }, // <---- here missing comma uglify: { build: { src: 'js/script.js', dest: 'js/script.min.js' } } });
make favor , use coffeescript!
module.exports = (grunt) -> grunt.initconfig pkg: grunt.file.readjson("package.json") concat: dist: src: ["components/js/*.js"] dest: "js/script.js" uglify: build: src: "js/script.js" dest: "js/script.min.js" grunt.loadnpmtasks "grunt-contrib-concat" grunt.loadnpmtasks "grunt-contrib-uglify" grunt.registertask "default", [ "concat" "uglify" ]
Comments
Post a Comment