concat order not working gulp4
miguelventura opened this issue · 2 comments
miguelventura commented
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
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
Thanks @phated,
The problem was exactly at the first glob './resources/js/**/*.js' is calling the other 2 files and is duplicating that.