尝试在单个任务中获得两个输出时出现此错误
我希望index.js
中的dist/
和index.min.js
位于同一文件夹中。
gulp.task('clean', (cb) =>
del('dist/', cb)
);
gulp.task('scripts', ['clean'], () =>
gulp.src('src/**.js')
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('dist/'))
.pipe($.uglify({preserveComments: 'some'}))
.pipe($.rename({ extname: '.min.js' }))
.pipe($.size({title: 'scripts'}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/'))
);
这是错误:
[19:48:55] Requiring external module babel-core/register
[19:49:00] Using gulpfile ~/projects/ar-string/gulpfile.babel.js
[19:49:00] Starting 'clean'...
[19:49:00] Finished 'clean' after 19 ms
[19:49:00] Starting 'scripts'...
events.js:85
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:1508:18)
at js_error (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:1516:11)
at croak (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2008:9)
at token_error (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2016:9)
at unexpected (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2022:9)
at semicolon (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2042:43)
at simple_statement (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2222:73)
at eval (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2095:19)
at eval (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2055:24)
at block_ (eval at <anonymous> (/home/mohamed/projects/ar-string/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:24:4), <anonymous>:2335:20)
注意:我认为错误是在巴贝尔
答案 0 :(得分:0)
抱歉,问题出在.babelrc文件
之前:
{
"presets": ["es2015"],
"only": "gulpfile.babel.js",
"retainLines": true
}
后:
{
"presets": ["es2015"],
"retainLines": true
}