Jcook894 Jcook894 - 2 months ago 34
Javascript Question

Gulp uglify running but not working

I set up my gulp task to minify js, But when I run gulp through the command line it runs but nothing is added to the file.

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


gulp.task('minifyjs', function(){

return gulp.src('views/js/*.js');
pipe(uglify()),
pipe(gulp.dest('dist'));
});

gulp.task('default',['minifyjs']);

Answer

This will work if you're running your Gulp task in such a project structure:

|
|_ Views
|   |_ JS
|       |_a.js
|_ gulpfile.js

Even in this case, try and make the folder './views/js/*.js', or '/views/js/*.js'