Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension problem (and suggested solution) #70

Open
ezequieltejada opened this issue Jul 10, 2016 · 3 comments
Open

Extension problem (and suggested solution) #70

ezequieltejada opened this issue Jul 10, 2016 · 3 comments

Comments

@ezequieltejada
Copy link

ezequieltejada commented Jul 10, 2016

Hello guys,

I came across with this problem, when I tried to run the HTML task...

gulp.task('html', ['javascript', 'stylesheet'], function () {
  var assets = $.useref.assets({searchPath: ['.tmp', 'app/*.html', './']});

  return gulp.src('app/*.html')
    .pipe(assets)
    //OTHER PIPES
    .pipe($.if('*.js', $.uglify().on('error', gutil.log)))
    .pipe($.if('*.css', $.csso()))
    //OTHER PIPES
    .pipe(gulp.dest('dist'));
});

... I got this error:

Error
    at new JS_Parse_Error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
    at parse_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1667:9)
    at Object.next_token [as input] (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1946:9)
    at next (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2075:25)
    at Object.parse (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2061:15)
    at /home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:71:33
    at Array.forEach (native)
    at Object.exports.minify (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:66:15)
    at /home/ezequiel/Escritorio/Modus/node_modules/gulp-uglify/minifier.js:65:22
  message: '/home/ezequiel/Escritorio/Modus/app/css/main.css: Unexpected character \'@\'',
  fileName: '/home/ezequiel/Escritorio/Modus/app/css/main.css',
  lineNumber: 1,
  stack: 'Error\n    at new JS_Parse_Error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)\n    at js_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)\n    at parse_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1667:9)\n    at Object.next_token [as input] (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1946:9)\n    at next (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2075:25)\n    at Object.parse (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2061:15)\n    at /home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:71:33\n    at Array.forEach (native)\n    at Object.exports.minify (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:66:15)\n    at /home/ezequiel/Escritorio/Modus/node_modules/gulp-uglify/minifier.js:65:22',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-uglify' }

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error
    at new JS_Parse_Error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
    at parse_error (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1667:9)
    at Object.next_token [as input] (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1946:9)
    at next (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2075:25)
    at Object.parse (eval at <anonymous> (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2061:15)
    at /home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:71:33
    at Array.forEach (native)
    at Object.exports.minify (/home/ezequiel/Escritorio/Modus/node_modules/uglify-js/tools/node.js:66:15)
    at /home/ezequiel/Escritorio/Modus/node_modules/gulp-uglify/minifier.js:65:22

and it's kind of weird, because it seems that "main.css" is getting through uglify even though the extension IS NOT ".js". So I changed the lines to

.pipe($.if('/\.js$/', $.uglify().on('error', gutil.log)))
//Instead of: .pipe($.if('*.js', $.uglify().on('error', gutil.log)))

.pipe($.if('/\.css$/b', $.csso()))
//Instead of: .pipe($.if('*.css', $.csso()))

and seems to be working fine.

I couldn't find the solution anywhere, so I hope this could be useful for anybody.

@prosenjit-manna
Copy link

@ezequieltejada Not working for me. Js compiled, no error in console in build time but JS not compiled properly.

@hjzheng
Copy link

hjzheng commented Apr 26, 2017

I have the same problem:

[02:22:03] Finished 'copy-modules' after 60 ms
events.js:160
      throw er; // Unhandled 'error' event
      ^
Error
    at new JS_Parse_Error (eval at <anonymous> (/var/jenkins_home/workspace/alidw-fe-ccms/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
    at js_error (eval at <anonymous> (/var/jenkins_home/workspace/alidw-fe-ccms/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
    at parse_error (eval at <anonymous> (/var/jenkins_home/workspace/alidw-fe-ccms/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1667:9)

@hjzheng
Copy link

hjzheng commented Apr 26, 2017

I found the reason: I use some es6 syntax, the uglify-js can not support it.

terinjokes/gulp-uglify#243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants