Gruntfile.js中的语法错误 - Sass Watch

时间:2014-04-11 21:13:40

标签: sass gruntjs watch

我第一次使用grunt.js而且我在设置sass手表时遇到了麻烦。我已经成功安装了node.js和grunt,我能够将所有javascript文件合并到一个文件中。然后我开始尝试让它来观察和编译我的sass文件,我无法弄清楚为什么我一直在我的命令行中得到这个错误(显然有一个语法错误,但我不知道它在哪里?

这是我的命令行错误:      曼迪在MandysMac的〜/ Desktop / Dropbox / WEBSITES / Portfolio / wp-content / themes / mandy_made_this_theme on master *      $ grunt

 /Users/Mandy/Desktop/Dropbox/WEBSITES/Portfolio/wp-content/themes/mandy_made_this_theme/Gruntfile.js:27
  watch: {
  ^^^^^
 Loading "Gruntfile.js" tasks...ERROR
 >> SyntaxError: Unexpected identifier
 Warning: Task "default" not found. Use --force to continue.

 Aborted due to warnings.

这是我的package.json文件:

 {
   "name": "mandy-made-this-theme",
   "version": "0.1.0",
   "devDependencies": {
   "grunt": "~0.4.2",
   "grunt-contrib-jshint": "~0.6.3",
   "grunt-contrib-nodeunit": "~0.2.0",
   "grunt-contrib-uglify": "~0.2.2",
   "grunt-contrib-sass": "^0.7.3",
   "grunt-contrib-watch": "^0.6.1"
   }
}

最重要的是,这是我的咕噜文件:

module.exports = function(grunt) {

 // Project configuration.
  grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  uglify: {
  options: {
    banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
  },
  build: {
    src: ['working/jquery-2.1.0.min.js, working/jquery-ui-1.10.4.custom.min.js',  'working/jquery.smooth-scroll.min.js', 'working/isotope.pkgd.min.js', 'working/scripts.js'], //input
    dest: 'scripts/build/scripts.min.js' //output
   }
  },

  sass: {                            
    dist: {                           
      options: {                      
        style: 'expanded'
      },
      files: {                     
        'style.css': 'sass/style.scss'       
      }
    }
  }

  watch: {
      css: {
        files: '**/*.scss',
        tasks: ['sass'],
        options: {
          livereload: true,
        }
      }
    }

  });

 // Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');

// Default task(s).
grunt.registerTask('default',['uglify', 'sass', 'watch']);

}

1 个答案:

答案 0 :(得分:1)

您在sass对象

之后缺少逗号
        'style.css': 'sass/style.scss'       
      }
    }
  }, // added , here

  watch: {
      css: {
        files: '**/*.scss',