【问题标题】:GulpUglifyError using gulp-webpack-vs2015GulpUglifyError 使用 gulp-webpack-vs2015
【发布时间】:2016-10-19 03:39:47
【问题描述】:

我遇到以下错误

events.js:160
      throw er; // Unhandled 'error' event
      ^
GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: punc ({) (line: 15, col: 7, pos: 1014)
Error
    at new JS_Parse_Error (eval at <anonymous> (C:\..\node_modules\gulp-uglify\node_modules\uglify-js\tools\node.js:1:0), <anonymous>:1545:18)

package.json

"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-less": "^3.1.0",
"gulp-sourcemaps": "^2.1.1",
"gulp-typescript": "^3.0.2",
"gulp-uglify": "^2.0.0",
"uglify-js-harmony": "^2.6.2"

在寻找答案后,看起来 gulp-uglify 依赖于 UglifyJS Issue with Babel, ES6 and Uglify,因此无法正常工作。另一方面,他们鼓励改用 uglify-js-harmony。但仍在查看 gulp-uglify\node_modules\uglify-js。如何强制 gulp 指向 uglify-js-harmony?

谢谢

【问题讨论】:

    标签: javascript visual-studio-2015 gulp gulp-uglify


    【解决方案1】:

    这个问题与我的另一个问题Gulp error with angular2有关,也需要只部署需要的文件,或者在上述情况下排除节点模块文件夹:

    tsconfig.json

    "files": [
        "angularApp/app/app.module.ts",
        "angularApp/main.ts"
      ],
    

    或排除(最好只包含需要的文件而不是排除所有节点模块)

    "exclude": [
        "node_modules"
      ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-03
      • 2017-03-27
      • 2015-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多