简体   繁体   English

Gulp缩小并且不复制原始文件

[英]Gulp minify and don't copy original files

I want to minify some JS files with Gulp, but can't seem to get control over the process. 我想用Gulp缩小一些JS文件,但似乎无法控制该过程。 I want only the minified version in the destination, and am currently getting copies of the originals as well. 我只想要目的地的缩版,并且目前也正在获取原件的副本。

I'm thinking I may need the rename package, but am not sure how to use it for this task - I would presumably need some kind of variable to hold the current file name for each script. 我在想可能需要重命名包,但不确定如何将其用于此任务-我可能需要某种变量来保存每个脚本的当前文件名。

Any help much appreciated. 任何帮助,不胜感激。 The code is below: 代码如下:

var gulp = require( 'gulp' );
var minify = require( 'gulp-minify' );
var rename = require( 'gulp-rename' );

//script paths
var jsFiles = 'js/**/*.js',
    jsDest = 'js/dist/';

gulp.task('scripts', function() {
    return gulp.src(jsFiles)
        .pipe(minify())
        .pipe(gulp.dest(jsDest));
});

像下面这样设置noSource配置

  .pipe(minify({noSource: true})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM