I'm using gulp-terser to minify js files. I have a jquery file and a custom js file. When I try to run the task, the custom js code is at the beginning of the jquery file. I've tried using gulp-order with it, but still no luck. Here's the code i'm using:
gulp.task('build-js', function () {
return gulp.src(["src/js/jquery.min.js","src/js/zinv.js"])
.pipe(concat('inv.min.js'))
.pipe(terser())
.pipe(gulp.dest('./js'));
});
thanks in advance.
I think you need to switch the position of .pipe(terser())
and .pipe(concat('inv.min.js'))
and call the require()
.
Try this :
var gulp = require('gulp');
var terser = require('gulp-terser');
var concat = require('gulp-concat');
gulp.task('js', function () {
return gulp.src(["src/js/jquery.min.js","src/js/zinv.js"])
.pipe(terser())
.pipe(concat('inv.min.js'))
.pipe(gulp.dest('js'));
});
gulp.task('default', gulp.series('js'));
And then on your terminal, navigate to the directory where your gulpfile.js is saved and type gulp
or gulp js