shellwe
shellwe

Reputation: 115

gulp-uglify not working

Here is my repository https://github.com/shellwe/QA_WP_Template

If you just needed to see the code snippet; here it is

gulp.task('uglify', function() {
      return gulp.src('js/all.min.js')
        .pipe(uglify())
        .pipe(gulp.dest('js/'));
});

I am running "gulp uglify" and I am getting the following errors.

events.js:160
      throw er; // Unhandled 'error' event
      ^
 Error
    at new JS_Parse_Error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1542:11)
    at croak (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2089:9)
    at token_error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2097:9)
    at unexpected (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2103:9)
    at semicolon (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2123:56)
    at simple_statement (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2314:73)
    at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2183:19)
    at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2136:24)
    at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2904:23)

Most examples I see had concat and uglify in one process but since the concat part was working I broke them apart to show that. I know its something wrong with uglify, I just can't figure out what I am doing wrong.

Upvotes: 1

Views: 5976

Answers (1)

goto
goto

Reputation: 4425

The error you are getting doesn't really explain much... However, according to the little "documentation" on npm.js of gulp-uglify,

To help properly handle error conditions with Node stream, this project recommends the use of pump

You can read up on gulp-uglify and pump.

So, I tried the following:

# grab pump
npm install pump --save-dev

Then, in the gulpfile.js, I did the following:

gulp.task('uglify2', function (cb) {
    pump([
        gulp.src('./js/all.min.js'),
        uglify(),
        gulp.dest('./js/')
    ],
    cb
    );
});

The error that I am getting, which by the way, is a lot nicer than the error you are getting, is the following:

enter image description here

The problem seems to be on line 191, which suggests that there is something wrong with your code, rather than your gulp task.

Upvotes: 4

Related Questions