В моем офисе мы используем gulp для сборки наших меньших файлов. Я хотел бы улучшить задачу сборки, поскольку потребовалось больше времени, чтобы построить крупный проект, над которым мы недавно работали. Идея заключалась в том, чтобы кэшировать файлы и передавать только те, которые были изменены. Итак, я начал с google и нашел инкрементные сборки для javascript ang, и было бы легко переписать их за меньшее. Здесь я начал с: https://github.com/gulpjs/gulp/blob/master/docs/recipes/incremental-builds-with-concatenate.md
После нескольких неудачных попыток я закончил с кодом (тестировался с последним дистрибутивом бутстрапа):
var gulp = require('gulp');
var less = require('gulp-less');
var concat = require('gulp-concat');
var remember = require('gulp-remember');
var cached = require('gulp-cached');
var fileGlob = [
'./bootstrap/**/*.less',
'!./bootstrap/bootstrap.less',
'!./bootstrap/mixins.less'
];
gulp.task('less', function () {
return gulp.src(fileGlob)
.pipe(cached('lessFiles'))
.pipe(remember('lessFiles'))
.pipe(less())
.pipe(gulp.dest('output'));
});
gulp.task('watch', function () {
var watcher = gulp.watch(fileGlob, ['less']);
watcher.on('change', function (e) {
if (e.type === 'deleted') {
delete cached.caches.scripts[e.path];
remember.forget('lessFiles', e.path);
}
});
});
Но это передает только измененный файл, а компилятор меньше, из-за отсутствия определений переменных. Если я подключаю конкат-плагин до меньшей задачи, gulp застревает в бесконечном цикле (по-видимому).
gulp.task('less', function () {
return gulp.src(fileGlob)
.pipe(cached('lessFiles'))
.pipe(remember('lessFiles'))
.pipe(concat('main.less')
.pipe(less())
.pipe(gulp.dest('output'));
});
Есть ли у кого-нибудь опыт работы с этими плагинами или ему удалось создать инкрементную меньшую сборку другим способом. Вот (беспорядочный) репозиторий github для тестирования: https://github.com/tuelsch/perfect-less-build
PS: Я планирую добавить linting, sourcemaps, minification, evtl. кэширование и автоопределитель позже.