Saturday 13 May 2017

concat one file first in gulp

I build my project with gulp, into a file called all.js. In my workspace I have one file which I call modules.js. In this file I declare all of my namespaces. I would like gulp to concat this file first, at the top of all.js, and only then the rest of the js files. This way I don't have to worry about files order, and any namespace being not defined.

Here is what I have tried:

gulp.src("./src/main/modules.js")
    .pipe(concat("all.js"))
    .pipe(gulp.src(["./src/**/*.js", "!./src/main/modules.js"]))
    .pipe(concat("all.js"))
    .pipe(gulp.dest(dist));

But this way, modules.js is all that I see in all.js. the rest of the files are not being written at all.

How can I tell gulp to write modules.js into all.js first, and then add the rest of the js files after it?

Thank you!



via Yogev

No comments:

Post a Comment