Grunt任务没有加载,得到无限循环

时间:2016-05-09 22:15:25

标签: javascript gruntjs

我无法正常加载我的咕噜咕噜的手表,sass,concat或uglify。 这是我的Gruntfile.js

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

    watch: {
        files: ['src/*.js'],
        tasks: ['jshint']
    },

    sass: {
        dist: {
            options: {
                style: 'compressed'
            },
            files: {
                [
                'src/*.css': 'main.scss',
                'widgets.css': 'widgets.scss'
                ]
            }
        }
    },

    concat: {
      js: {
        src: 'src/*.js',
        dest: 'src/build/concatenated.js'
      }
},


    uglify: {
  build: {
    src: 'src/build/concatenated.js',
    dest: 'src/build/concatenated.min.js'
  }
}

});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-sass');

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

};

在我的终端中,当我输入' grunt'我收到错误消息:

Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token :
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

我没有在任何地方看到额外的分号。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

files: {
         [
           'src/*.css': 'main.scss',
            'widgets.css': 'widgets.scss'
          ]
       }

应该是

files: {
          'src/*.css': 'main.scss',
          'widgets.css': 'widgets.scss'
       }