我有以下gulpfile:
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var traceur = require('gulp-traceur');
var concat = require('gulp-concat');
var uglify = require('gulp-uglifyjs');
gulp.task('default', function () {
return gulp.src('src/*.js')
.pipe(sourcemaps.init())
.pipe(traceur())
.pipe(concat('all.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
运行此代码时,我无法在all.js文件中获取源地图。
当我删除该行时:
.pipe(uglify())
我得到了源地图,但后来我的代码没有被证实。
我尝试使用gulp-utils调试代码,但没有找到任何内容(how to debug gulp-sourcemaps not doing anything?)。
如何修复此问题?
答案 0 :(得分:1)
我改变了#gulp-uglifyjs'到' gulp-uglify'一切正常
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var traceur = require('gulp-traceur');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util')
gulp.task('default', function () {
return gulp.src('src/*.js')
.pipe(sourcemaps.init().on('error', gutil.log))
.pipe(traceur())
.pipe(concat('all.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});