0

我的 Gruntfile.js 中有以下内容:

concat: {
  options: {
    // define a string to put between each file in the concatenated output
    separator: ';'
  },
  dist: {
    // the files to concatenate
    src: [
        'scripts/jquery.easing.1.3.js', 
        'scripts/SmoothScroll.js',
        'scripts/jquery.parallax-1.1.3.js', 
        'scripts/jquery.bxslider.js',
        'scripts/jquery.hoverdir.js', 
        'scripts/jquery.mixitup.js',
        'scripts/jquery.fitvids.js', 
        'scripts/respond.min.js',
        'scripts/theme.script.js', 
        'scripts/theme.settings.js'
    ],
    // the location of the resulting JS file
    dest: 'scripts.js'
  }
}

但是当我跑步时,grunt concat什么也没有发生。任务已加载并注册:

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('concat', ['concat']);

我没有收到任何错误,但scripts.js没有创建文件。知道我做错了什么吗?

4

2 回答 2

0

在文件中添加 src 和 dest:

concat: {
  options: {
    // define a string to put between each file in the concatenated output
    separator: ';'
  },
  dist: {
    files:[{
    // the files to concatenate
    src: [
        'scripts/jquery.easing.1.3.js', 
        'scripts/SmoothScroll.js',
        'scripts/jquery.parallax-1.1.3.js', 
        'scripts/jquery.bxslider.js',
        'scripts/jquery.hoverdir.js', 
        'scripts/jquery.mixitup.js',
        'scripts/jquery.fitvids.js', 
        'scripts/respond.min.js',
        'scripts/theme.script.js', 
        'scripts/theme.settings.js'
    ],
    // the location of the resulting JS file
    dest: 'scripts.js'
    }]
  }
}
于 2015-04-14T21:55:52.503 回答
0

有什么意义grunt.registerTask('concat', ['concat']);

使用相同的名字是灾难的根源。只需删除该行,然后再试一次grunt concat

于 2014-03-04T17:01:47.130 回答