Search code examples
gruntjsgruntfile

Where is the Syntax Error? (gruntfile.js)


module.exports = function(grunt) {
 // Project configuration.
 grunt.initConfig({
   pkg: grunt.file.readJSON('package.json'),
    connect: {
     uses_defaults: {}
   },
    sass: {
     dev: {
       options: { sourceMap: true },
       files: { 'sites/all/themes/uj/css/uj.styles.css' : 'sites/all/themes/uj/sass/uj.styles.scss' }     
    }
   },
   watch: {
    css: {
      files: 'sites/all/themes/uj/sass/**/*.scss',
      tasks: [ 'sass:dev' ]
      options: { livereload: true }
 }
}



 });
 // Load Grunt plugins
 grunt.loadNpmTasks('');
 // Default task(s).
 grunt.registerTask('default', []);



// Load Grunt plugins
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');


};

I don't understand javascript, but I have to deal with it this time. Please pick the mistake for me :)

This is my errormessage:

Loading "gruntfile.js" tasks...ERROR SyntaxError: Unexpected identifier Warning: Task "sass" not found. Use --force to continue.

Aborted due to warnings.


Solution

  • You are missing a comma inside the watch target:

     watch: {
        css: {
          files: 'sites/all/themes/uj/sass/**/*.scss',
          tasks: [ 'sass:dev' ], //<-- missing comma added here
          options: { livereload: true }
     }
    

    Also remove the empty load call: grunt.loadNpmTasks(''); it is redundant.