gulp-minify without rename original files

梦想与她 提交于 2019-12-11 09:59:41

问题


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"));
});

回答1:


Use gulp-uglify instead - it doesn't rename files, which is the default behavior for most gulp plugins.

var gulp = require('gulp');
var uglify = require('uglify');

gulp.task("js-external-release", function() {
    gulp.src(config.vendorJs)
        .pipe(uglify())
        .pipe(gulp.dest(config.dist + "/scripts"));
});

Alternatively, you could use gulp-rename, but switching to uglify will eliminate the need for such a plugin and is less complex than adding a new plugin in my opinion.



来源:https://stackoverflow.com/questions/33881413/gulp-minify-without-rename-original-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!