Skip to content

Commit

Permalink
Fixed prevent gulp from breaking if paths are not defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmarz authored and wrux committed Jun 1, 2021
1 parent aad715d commit d61d489
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 17 additions & 7 deletions tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ module.exports = (gulp, $, pkg) => {
const watch = (callback) => {
// Fractal automatically detects existing server instance.
$.livereload.listen();
gulp.watch(pkg.gulpPaths.fonts.src, gulp.series('fonts'));
gulp.watch(pkg.gulpPaths.icons.src, gulp.series('icons'));
gulp.watch(pkg.gulpPaths.images.src, gulp.series('images'));
gulp.watch(pkg.gulpPaths.styles.src, gulp.series('styles'));
gulp.watch(pkg.gulpPaths.scripts.src, gulp.series('scripts'));
gulp.watch(pkg.gulpPaths.templates, (files) => {
$.livereload.changed(files);
const tasks = [
'fonts',
'icons',
'images',
'styles',
'scripts',
];
tasks.forEach((task) => {
const path = pkg.gulpPaths?.[task]?.src;
if (path) {
gulp.watch(path, gulp.series(task));
}
});
if (pkg.gulpPaths?.templates) {
gulp.watch(pkg.gulpPaths.templates, (files) => {
$.livereload.changed(files);
});
}
callback(); // Required to stop Gulp throwing async competion error.
};

Expand Down
5 changes: 3 additions & 2 deletions tasks/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module.exports = (gulp, $, pkg) => {
// @task: Process and minify images.
const minify = () => {
const minify = async () => {
if (!pkg.gulpPaths?.images?.src) { return false }
return gulp.src(pkg.gulpPaths.images.src)
.pipe($.imagemin([
$.imagemin.gifsicle({ interlaced: true }),
Expand All @@ -15,7 +16,7 @@ module.exports = (gulp, $, pkg) => {
};

const inlineSvg = async () => {
if (!pkg.gulpPaths.images.inlineSvgs === true) { return false }
if (!pkg.gulpPaths?.images?.inlineSvgs === true) { return false }
return gulp.src(pkg.gulpPaths.images.dest + '/**/*.svg')
.pipe($.sassvg({
outputFolder: pkg.gulpPaths.styles.srcDir + '/vendor'
Expand Down

0 comments on commit d61d489

Please sign in to comment.