gruntjs / grunt-contrib-concat

Concatenate files.
http://gruntjs.com/
MIT License
812 stars 170 forks source link

concat in specific order; not alphabetically #182

Open utdrmac opened 6 years ago

utdrmac commented 6 years ago

I'm using "grunt-contrib-concat": "^1.0.1". Here's gruntfile parts:

concat: {
  options: { separator: ';' },
  dist: {
    src: [
      'node_modules/jquery/dist/jquery.min.js',
      'node_modules/bootstrap/dist/js/bootstrap.min.js',
      'baller.js',
    ],
    dest: 'app.js'
  }
},

When I do more app.js on CLI, I am expecting see "jquery.min.js" first, then "bootstrap.min.js" next, then "baller.js" last. But "baller.js" is always first, followed by bootstrap, then jquery.

If you change baller.js to "zzz.js", then "zzz.js" is the last part of app.js

Why is grunt-concat not honoring the file names order?

rquadling commented 6 years ago

We had the same issue. Our solution was to not use the globbing in concat.

This is one of my concat setups..

            customer_js: {
                options: {
                    sourceMap: false
                },
                src: customerJsSources,
                dest: 'public/js/customer.js'
            },

customerJsSources is ...


    var customerJsSources =
        [].concat(
            commonJsSourcesStart,
            ['src/customer/js/routes.js'],
            commonJsSourcesEnd,
            Glob.sync('src/customer/js/**/*.js', {nocase: true}),
            ['src/customer/js/4-run.js']
        );

Explicit ordering. Hundreds of files concatenated in the correct order.