gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 126 forks source link

concat order not working gulp4 #153

Closed miguelventura closed 4 years ago

miguelventura commented 4 years ago

I'm trying to migrate for Gulp 4 and since that, gulp ignore the src files ordering. Also i've trying gulp-order but it still the same. This is how my gulp file looks:

Gulp version: 4.0.2

function scripts() {
    return src(['./resources/js/**/*.js', './resources/js/formvalid.js', './resources/js/main.js'])
        .pipe(plumber())
        .pipe(concat('scripts.js'))
        .pipe(uglify())
        .pipe(dest(dist));
}
exports.scripts = scripts;

Can you help me to fix this?

phated commented 4 years ago

What happens if you remove plumber? That module shouldn't be used with gulp 4, and instead you should be using stream.pipeline from node core like:

function scripts() {
    return stream.pipeline(
        src(['./resources/js/**/*.js', './resources/js/formvalid.js', './resources/js/main.js']),
        concat('scripts.js'),
        uglify(),
        dest(dist),
    ]);
}
exports.scripts = scripts;

Be aware that stream order is only guaranteed between each glob pattern and not inside a glob itself since your filesystem is traversed async while performing the glob itself.

miguelventura commented 4 years ago

Thanks @phated, The problem was exactly at the first glob './resources/js/*/.js' is calling the other 2 files and is duplicating that.