简体   繁体   中英

Error from uglify in compress task Error in plugin 'gulp-uglify'

[12:20:17] Finished 'images' after 12 s
Error from uglify in compress task Error in plugin 'gulp-uglify'
Message:
    D:\projects\Source\app\scripts\vendor.js: SyntaxError: Unexpected token: keyword (default)
Details:
    fileName: D:\projects\Source\app\scripts\vendor.js
    lineNumber: 96908
[12:23:39] Finished 'fonts' after 3.55 min
[12:23:49] Finished 'jshint' after 3.75 min

I am getting above error on gulp Build. so far i have tried all solutions of GulpUglifyError:Unable to minify JavaScript to no success. any ideas?

Follow this example with uglifyes or use Babel or (if you use it) TypeScript to output to ES5.

Make sure to read the documentation more closely.

Example:


var uglifyes = require('uglify-es'); // for ES support
var composer = require('gulp-uglify/composer'); // for using a different uglify runtime/config

var uglify = composer(uglifyes, console); // setup the new uglify constant

function javascriptTask ( done ) {

    gulp.src("[[file location]]")
        // [pipe processing]
        .pipe(uglify())
    done(); // this tells Gulp 4 that the task is done
    
}

let main = gulp.[series | parallel](javascriptTask); // edit out series or parallel depending on needs

export default = main // allows you launch all tasks in the gulp.[series | parallel] from the terminal with gulp

You can also use gulp-terser

For transpiling

For a babel solution: click here

If you use TypeScript you should have target: 'es5' in your .tsconfig , tsify (for browserify ) or gulp-typescript object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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