Error from uglify in compress task Error in plugin 'gulp-uglify'
Asked Answered
B

1

0
[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?

Blinker answered 6/7, 2021 at 16:28 Comment(0)
O
0

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.

Octoroon answered 31/3, 2022 at 8:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.