Answer the question
In order to leave comments, you need to log in
Gulp.js file not compiling?
The files are divided into two types, with and without underscores at the beginning of the file name, the first ones are not compiled into the final build, as they are imported into other files.
The problem is that when there is a change in these files (with an underscore), the reload of the page is triggered but the changes are not visible.
If you display debag in the task, you can see that there are no changes.
If you comment '!src/less/**/_*.less'
out the changes, the changes are visible, but the build now contains files with underscores.
I can of course go through the build after compilation and delete all files with an underscore, but I think there is a better solution.
Can you please tell me how to get changes in ignored files into the build?
gulp.task('less', function () {
return gulp.src([
'src/less/**/*.less',
'!src/less/**/_*.less' // игнорирование файлов с нижним подчеркиванием
], {since: gulp.lastRun('less')}) // сборка только измененых файлов
.pipe(debug({title: 'end less'}))
.pipe(less()).on('error', notify.onError(function(err){
return {
title: 'error less',
message: err.message
};
}))
.pipe(gulp.dest('build/css'));
});
gulp.task('watch', function() {
gulp.watch('src/less/**/*.less', gulp.series('less'));
});
Answer the question
In order to leave comments, you need to log in
This is how it is possible, but files deeper src/less/
will not get into the final file unless they are imported.
[
'src/less/*.less',
'!src/less/**/_*.less' // игнорирование файлов с нижним подчеркиванием
]
_*.less
from the folder src/less/
one level up.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question