2016-03-18 12 views
2

Ich versuche, uglifyJS2 zu verwenden, um alle JavaScript-Dateien (von ZURB Foundation 6 einschließlich einiger benutzerdefinierten) in einer einzigen Datei zu verketten.UglifyJS2 Thows Parse Fehler (Unerwartete Token: Name (Abide)) jedes Mal

In einem kommenden Projekt kann ich nicht einfach ZURB Yeti Launch-Anwendung verwenden. Also plane ich beide sass für scss Dateien (funktioniert bereits) und uglifyjs2 für JavaScript-Dateien über die Befehlszeile.

Leider kann ich nicht bekommen uglifyjs2, um die Skripte durch das Feuer des folgenden Befehl in der Befehlszeile verketten:

uglifyjs foundation-sites/js/*.js -o foundation-stes/dist/foundation.min.js

Es führt den folgenden Fehler, auch wenn ich Eingabe nur eine einzige Datei (wie foundation.abide.js) :

Parse error at foundation-sites/js/foundation.abide.js:10,6 Unexpected token: name (Abide) Error at new JS_Parse_Error (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1526:18) at js_error (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1534:11) at croak (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2026:9) at token_error (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2034:9) at unexpected (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2040:9) at semicolon (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2060:56) at simple_statement (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2240:73) at eval (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2113:19) at eval (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2073:24) at block_ (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2353:20)

Aber wenn ich schreibe einige grundlegende Skripte es perfekt funktioniert. Gibt es irgendetwas, was ich falsch mache? Kann mir jemand einen hilfreichen Hinweis geben?

Antwort

6

Sie müssen ES6 in ES5 umwandeln, bevor Sie uglifyjs verwenden. Im Moment unterstützt uglifyjs keine ES6 Syntax. Sie können babel dafür verwenden. Siehe mehr https://babeljs.io/.