GulpUglifyError:Unable to minify JavaScript

前端 未结 8 1855
感情败类
感情败类 2021-01-31 02:06

I am trying to minify my script files for which i am using gulp task runner And I am trying gulp-uglify plugin

Code:

 gulp.task(\'concat\', function() {         


        
8条回答
  •  无人共我
    2021-01-31 02:22

    The main error to Unable to minifies JavaScript is the path not found. You can use the task usemin For this you need:

    $ sudo npm install gulp-usemin --save-dev
    $ sudo npm install gulp-livereload --save-dev
    $ sudo npm install gulp-util --save-dev
    

    and requires :

    var usemin = require('gulp-usemin');
    var livereload = require('gulp-livereload');
    var gutil = require('gulp-util'); //gutil for error display
    
    gulp.task('usemin',['jshint'], function(){
        return gulp.src('./app/index.html')
        .pipe(usemin({
            css: [minifycss(),rev()],
            scripts: [uglify().on('error', function(err) {gutil.log(gutil.colors.red('[Error]'), err.toString());this.emit('end');}),rev()]
        })) 
        .pipe(gulp.dest('dist'))
        .pipe(livereload());
    });
    
    Change the js: [uglify(), rev()] to scripts: [uglify(), rev()]
    

提交回复
热议问题