无法理解我在哪里出错(如果它是我的话),我已经得到了我的(第一个)gulp文件,并且它工作正常:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var del = require('del');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
gulp.task('default', ['clean', 'minify-external', 'minify-internal']);
gulp.task('clean', function() {
del(['build/js/'], function(err){ });
});
gulp.task('minify-external', function() {
return gulp.src([
'bower_components/jquery/dist/jquery.js',
'bower_components/handlebars/handlebars.js',
'bower_components/ember/ember.js',
'bower_components/ember-data/ember-data.js',
])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('scripts.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/js/'));
});
gulp.task('minify-internal', function() {
return gulp.src('src/js/**/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('lib.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/js//'));
});
gulp.watch('src/js/**/*.js', ['minify-internal']);
接下来,我正在尝试将手柄预编译添加到其中:
//above omitted for brevity
gulp.task('default', ['clean', 'minify-external', 'minify-internal']);
//...
gulp.task('templates', function() {
return gulp.src('src/templates/**/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'Todos.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.min.js'))
.pipe(gulp.dest('build/js/'));
});
现在脚本失败了:
Error: EEXIST, mkdir '[BUILD PATH]/build/js'
似乎特定于templates
任务,因为其他两个minify-x
任务运行正常。我尝试过异步和同步运行(即从任务中删除return语句)。我错过了关于流如何在这里互动的内容吗?从多个任务输出到同一个文件夹是否正常?