It is possible minify js files without add -min suffix?
I want keep original name.
gulp.task("js-external-release", function() {
gulp.src(config.vendorJs)
.pipe(minify())
.pipe(gulp.dest(config.dist + "/scripts"));
});
This is a very old question, but it still pops up quite high on Google, and since Uglify is no longer actively maintained for ES6+ and gulp-minify
is, I thought I’d add that it is (now) perfectly possible to do this with gulp-minify
.
If you specify the extension of minified files to be just .js
(or whatever your input file extension is) in your gulp-minify
options, the minified file will have the same file name as the original. The problem is that gulp-minify
by default also compiles a non-minified copy of the input file to the output directory – and that non-minified copy gets added after the minified copy, thus overwriting it and leaving you with just a copy of the original.
To get around this, set the noSource
option to true – then no copy of the input file is output:
gulp.task("js-external-release", function() {
gulp.src(config.vendorJs)
.pipe(minify({
ext: {
min: '.js' // Set the file extension for minified files to just .js
},
noSource: true // Don’t output a copy of the source file
}))
.pipe(gulp.dest(config.dist + '/scripts'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With