0

I've got the following in my 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'
  }
}

But when I run grunt concat nothing happens. The task is loaded and registered with:

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

I don't get any errors, but the file scripts.js is not created. Any idea what I'm doing wrong?

babbaggeii
  • 7,577
  • 20
  • 64
  • 118
  • What's the point of `grunt.registerTask('concat', ['concat']);` ? Using the same name is a recipe for disaster. Just remove that line and try again `grunt concat`. – Mangled Deutz Mar 04 '14 at 16:03
  • Ah, that's what the problem was. I thought that you had to register all tasks but I guess that is just for doing multiple tasks? – babbaggeii Mar 04 '14 at 16:06
  • Well, you need to register a task if you are actually creating a new one. Here, you are barely *using* the concat task (defined by the plugin). Anyhow, did that solve your problem? – Mangled Deutz Mar 04 '14 at 16:12
  • Yes it did. Thanks very much. If you write it as an answer, I'll accept it. – babbaggeii Mar 04 '14 at 16:22
  • I posted it as an answer. Happy it helped! Best. – Mangled Deutz Mar 04 '14 at 17:02

2 Answers2

0

What's the point of grunt.registerTask('concat', ['concat']); ?

Using the same name is a recipe for disaster. Just remove that line and try again grunt concat.

Mangled Deutz
  • 11,384
  • 6
  • 39
  • 35
0

add src and dest inside files:

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'
    }]
  }
}
patz
  • 1,306
  • 4
  • 25
  • 42