hustxiaoc / gulp-minify

minify js plugin for gulp
BSD 2-Clause "Simplified" License
65 stars 20 forks source link

When minifying with same src and ext output files aren't minified #33

Closed bencun closed 6 years ago

bencun commented 6 years ago

Edit: Nevermind, my bad, I overlooked the noSource: true option that does exactly this, it solved my issue! Still, I believe gulp-minify should automatically skip saving original source files if it detects that ext.src == ext.min.

Pre-edit: I have this simple piece of code that does not work:

//minify js
gulp.task('buildminify', ['buildcore', 'buildrequire'], function(){
    return gulp.src('tmp/scripts/**/*.js', {base: './'})
        .pipe(minifyJS({
            ext:{
                src: '.js',
                min: '.js'
            }
        }))
        .pipe(gulp.dest('./'));
});

Of course, when I change min: '.js' to min: '.min.js' files are being created and minified properly and I get both original files and the minified files in the target folders. But if I leave extensions the same output files aren't being overwritten with their minified versions.

Is this a desired behavior or a limitation of gulp-minify, or perhaps gulp itself? Is there a way around this except for manually removing original files and renaming minified files after the minification is complete?