dowjones / gulp-bundle-assets

Create static asset (js, css) bundles from a config file: a common interface to combining, minifying, revisioning and more
MIT License
133 stars 36 forks source link

consistent concat order #25

Closed chmontgomery closed 9 years ago

chmontgomery commented 10 years ago

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

RyanS commented 9 years ago

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

timelf123 commented 9 years ago

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

chmontgomery commented 9 years ago

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.

timelf123 commented 9 years ago

That looks great to me. Pretty easy to understand too

chmontgomery commented 9 years ago

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