Search code examples
javascriptgruntjsbowergrunt-contrib-concat

using grunt-contrib-concat with bower


i have this situation:

  • i have some js libraries downloaded via bower in bower_componenents folder
  • some custom javascript in a different js folder

my concat task is the following:

concat: {
  dist: {
    src: [
      'bower_components/jquery/jquery.js',
      'bower_components/imagesloaded/imagesloaded.js',
      'js/libs/*.js',
      'js/custom/*.js'
    ],
    dest: 'js/build/production.js'
  }
}, //end concat

the result gets then processed by grunt uglifier like so:

uglify: {
  dist: {
    src: 'js/build/production.js',
    dest: '_site/js/production.min.js'
  }
}, //end uglify

what happens here is everything goes smoothly if i add just ONE library from bower_components folder (in my case jquery). if i add a second one (in my case images loaded), the resulting javascript file gets broken and no javascript works at all.

if i inspect the production.min.js file i notice all the needed code is actually there, but it doesn't work.

what am i missing? should i use grunt-bower-concat? if yes, why and will it concatenate also my custom js?

for a reference, i'm using this grunt boilerplate: https://github.com/vlrprbttst/grunt-boilerplate-v2

thanks!!


Solution

  • that's fixed with:

        concat: {
            options: {
                separator: ';',
            },
            dist: {
    

    and

        uglify: {
            options: {
                mangle: false
            },
            dist: {