dowjones/gulp-bundle-assets

consistent concat order

chmontgomery opened this issue · 5 comments

Right now, custom transforms can cause the files in stream to stream through in a seaminly random order. Perhaps use something like gulp-order to make this deterministic: https://www.npmjs.org/package/gulp-order

This would def be good to have. Was trying this out and included gulp-hogan to precompile mustache templates. No matter what I did the compiled templates were at the bottom of the file which was problematic

Every time my js bundles are built the script load order changes. Sometimes this causes errors and causes the app to fail

Thinking through the config that would represent this feature... what do people think about this?:

// bundle.config.js
header: {
    scripts: [
        {
            src: './bower_components/jquery/dist/jquery.js',
            minSrc: './bower_components/jquery/dist/jquery.min.js'
        },
        './vendor/*.js',
        './content/*.coffee',
        './content/*.js'
    ],
    styles: [
        //...
    ],
    options: {
        order: {
            scripts: [
                'always-first.js',  // from /content/*.js
                'jquery*.js',       // depending on env, this could be streaming min or non-min file so use wildcard
                'lodash.js',        // from /vendor 
                'file1.js',         // compiled from file1.coffee
                'file2.js',         // compiled from file2.coffee
                '!always-last.js',  // everything else except always-last.js
                'always-last.js'    // from /content/*.js
            ],
            styles: [
                //...
            ]
        }
    }
}

The config is based off what gulp-order natively supports.

That looks great to me. Pretty easy to understand too

@RyanS @timelf123 can you pull down v2.22.0 and verify if this feature works for you? Thanks!