我使用gulp-uglify
和gulp-concat
缩小并连接我的js文件,如下所示:
gulp.task('scripts', function() {
gulp.src([
'./development/assets/js/lib/jquery-1.11.2.min.js',
'./development/assets/js/lib/foundation.min.js',
'./development/assets/js/lib/angular.min.js',
'./development/assets/js/lib/angular.min.js.map',
'./development/assets/js/lib/angular-ui-router.min.js',
'./development/assets/js/lib/angular-animate.js',
'./development/assets/js/lib/angular-sanitize.min.js',
'./development/assets/js/lib/loading-bar.min.js',
'./development/assets/js/lib/angular-sanitize.min.js',
'./development/assets/js/lib/toastr.min.js',
'./development/assets/js/lib/angular-datepicker.js',
'./development/assets/js/lib/angucomplete-alt.js',
'./development/assets/js/lib/d3.v3.min.js',
'./development/assets/js/lib/mm-foundation.min.js',
'./development/assets/js/lib/ng-text-truncate.js',
'./development/assets/js/lib/angular-lazy-loader.min.js',
'./development/assets/js/lib/jquery-jvectormap-2.0.3.min.js',
'./development/assets/js/lib/jquery-jvectormap-world-mill.js',
'./development/assets/js/lib/jquery.tagcanvas.min.js',
'./development/assets/js/lib/angular-touch.min.js',
'./development/assets/js/lib/slick.min.js',
'./development/assets/js/lib/angular-slick.min.js',
'./development/assets/js/lib/d3.tip.js',
'./development/assets/js/lib/angular-pageslide-directive.js',
'./development/assets/js/app.js',
'./development/assets/js/lib/upload.js',
'./development/assets/js/controllers/**/*.js',
'./development/assets/js/services/**/*.js',
'./development/assets/js/filters/**/*.js',
'./development/assets/js/directives/**/*.js'
])
.pipe(concat('production.js'))
.pipe(uglify())
.pipe(gulp.dest('./production/assets'))
})
但是,当我运行gulp scripts
时,我会得到一个错误。这是错误堆栈跟踪:
events.js:85
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:1526:18)
at js_error (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:1534:11)
at croak (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2025:9)
at token_error (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2033:9)
at unexpected (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2039:9)
at semicolon (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2059:43)
at simple_statement (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2239:73)
at eval (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2092:47)
at eval (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2072:24)
at block_ (eval at <anonymous> (/home/project/static/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2352:20)
知道出了什么问题吗?Gulp版本为3.9.0,节点版本为0.12.7。
发现问题。由CCD_ 4引起。uglify
无法处理映射文件。