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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.