尝试在gulp / babelify / browserify项目上执行源流时,我得到了一个相当无法解决的解析器错误。错误是:
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: app.js.map: error: couldn't process source due to parse error
Unexpected token (1:10)
我的gulp配置如下:
var path = require('path');
var gulp = require('gulp');
var babelify = require('babelify');
var ngAnnotate = require('gulp-ng-annotate');
var browserSync = require('browser-sync');
var browserify = require('browserify');
var sourceMaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var $ = require('gulp-load-plugins')();
browserify({
//cache: {},
//packageCache: {},
// fullPaths: true,
debug: true,
entries: options.src + '/app/app.js',
paths: ['./src'],
extensions: [' ', 'js']
})
// .add(require.resolve('babel-polyfill'))
.transform(babelify.configure({
"presets": ["es2015"],
ignore: [
'/bower_components',
'/node_modules'
]
}))
.bundle()
// .on('error', util.log.bind(util, 'Browserify Error'))
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourceMaps.init({loadMaps: true}))
.pipe(uglify({mangle: false}))
.pipe(sourceMaps.write('./', {sourceRoot: './js'}))
.pipe(gulp.dest(options.tmp + '/serve/app'))
.pipe(ngAnnotate())
.pipe($.replace('__API_URL__', process.env['API_URL'] || 'http://devint.api.com'));
任何可能导致此错误的想法?
答案 0 :(得分:1)
在ngAnnotate()
之前通过uglify()
。