有没有人找到可以生成有效源映射的 Gulp、Uglify 和 Concat 的有效组合? GitHub 中似乎有很多关于此类交互的问题,但同样人们似乎已经找到了成功的组合。我尝试了多种变体,但当我打开 uglify 时,符号映射不起作用并且断点在浏览器中无法正常工作。例如,以下工作正常:
return gulp.src('/scripts/*.js')
.pipe(sourcemaps.init())
//.pipe(uglify())
.pipe(concat(outputName + '.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(outputPath))
.on('end', function() { gutil.log('Minified ' + outputName); })
.on('error', handleError);
但是取消注释 uglify 并且它没有。
我创建了一个 GitHub 存储库来重现该问题:https://github.com/jamescrowley/gulpIssues
最佳答案
我们一直将其用作:
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('app.js'))
这对我来说似乎很管用。不过,它将源映射输出到文件本身。
版本:
"browser-sync": "^2.2.4",
"gulp": "^3.8.6",
"gulp-concat": "^2.3.4",
"gulp-ng-annotate": "^0.2.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0",
"gulp-sourcemaps": "^1.1.0",
"gulp-uglify": "^0.3.1",
"gulp-util": "^2.2.20"
关于javascript - 如何使用 Gulp、Uglify 和 Concat 生成有效的 Source Maps?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30281998/