У меня была такая же проблема с Gulp, поскольку различные задачи, связанные с несколькими пунктами назначения, кажутся трудными или потенциально невозможными. Кроме того, настройка нескольких потоков для одной задачи кажется неэффективной, но я думаю, что это решение на данный момент.
Для моего текущего проекта мне понадобилось несколько связок для связи с различными страницами. Модификация GULP Starter
https://github.com/greypants/gulp-starter
browserify/watchify задача:
https://github.com/dtothefp/gulp-assemble-browserify/blob/master/gulp/tasks/browserify.js
Я использовал цикл по каждому элементу внутри модуля Глоб обратного вызова:
gulp.task('browserify', function() {
var bundleMethod = global.isWatching ? watchify : browserify;
var bundle = function(filePath, index) {
var splitPath = filePath.split('/');
var bundler = bundleMethod({
// Specify the entry point of your app
entries: [filePath],
// Add file extentions to make optional in your requires
extensions: ['.coffee', '.hbs', '.html'],
// Enable source maps!
debug: true
});
if(index === 0) {
// Log when bundling starts
bundleLogger.start();
}
bundler
.transform(partialify)
//.transform(stringify(['.html']))
.bundle()
// Report compile errors
.on('error', handleErrors)
// Use vinyl-source-stream to make the
// stream gulp compatible. Specifiy the
// desired output filename here.
.pipe(source(splitPath[splitPath.length - 1]))
// Specify the output destination
.pipe(gulp.dest('./build/js/pages'));
if(index === (files.length - 1)) {
// Log when bundling completes!
bundler.on('end', bundleLogger.end);
}
if(global.isWatching) {
// Rebundle with watchify on changes.
bundler.on('update', function(changedFiles) {
// Passes an array of changed file paths
changedFiles.forEach(function(filePath, index) {
bundle(filePath, index);
});
});
}
}
// Use globbing to create multiple bundles
var files = glob('src/js/pages/*.js', function(err, files) {
files.forEach(function(file, index) {
bundle(process.cwd() + '/' + file, index);
})
});
});
Не можем ли мы сохранить результат расслоения(), 'вар расслоении = browserify (» ./ SRC/index.js') расслоение();. ' , а затем кормить его до 2 разные «трубопроводы»? как 'bundle.pipe (source ('bundle.js')). Pipe (gulp.dest ('./ dist'));' и 'bundle.pipe (rename ('bundle.min.js')) .pipe (streamify (uglify()) .pipe (gulp.dest ('./ dist')); ' , поэтому пакет запускается один раз, и мы используем результат дважды. – AntouanK
Из какой версии глотки эта ошибка исправлена ? –
@AlirezaMirian +1 за то, что хочет узнать, какая версия была исправлена – anjunatl