I want to minify some JS files with Gulp, but can't seem to get control over the process. 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));
});
I want to minify some JS files with Gulp, but can't seem to get control over the process. 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));
});
Share
Improve this question
edited May 27, 2018 at 13:02
Jan Bodnar
11.7k6 gold badges71 silver badges83 bronze badges
asked Apr 18, 2018 at 16:08
Robin AndrewsRobin Andrews
3,80412 gold badges55 silver badges128 bronze badges
1
- The minified files are written under js/**/*.js too ???? – Alejandro Teixeira Muñoz Commented Apr 18, 2018 at 16:12
1 Answer
Reset to default 12Set the noSource
config like the following
.pipe(minify({noSource: true})