From f43c24ea0c762d32fc7dabbf398b9afadec77fc4 Mon Sep 17 00:00:00 2001 From: Felix Haeberle <f.haeberle@tojio.com> Date: Mon, 28 Jan 2019 15:14:23 +0100 Subject: [PATCH] add support for gulp v4 --- templates/gulpfile.js.twig | 12 ++++++++---- templates/package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/templates/gulpfile.js.twig b/templates/gulpfile.js.twig index 3e7412f..266ce54 100644 --- a/templates/gulpfile.js.twig +++ b/templates/gulpfile.js.twig @@ -21,8 +21,12 @@ var autoprefixer = require('autoprefixer'), }, options = minimist(process.argv.slice(2), knownOptions); +{# This variable is needed to search for defined fonts in packages #} +{% set fontDefined = false %} + {% for name, package in bower_assets %} {% if package.fonts is defined %} +{% set fontDefined = true %} // Provide fonts from {{ name }} gulp.task('fonts-{{ package.name }}', function() { return gulp.src('{{ package.fonts.relative }}/**') @@ -32,7 +36,7 @@ gulp.task('fonts-{{ package.name }}', function() { {% endif %} {% endfor %} // Provide fonts from all libraries -gulp.task('fonts', [{% for name, package in bower_assets %}{% if package.fonts is defined %}'fonts-{{ package.name }}', {% endif %}{% endfor %}]); +gulp.task('fonts', {% if fontDefined %}gulp.series(gulp.parallel({% for name, package in bower_assets %}{% if package.fonts is defined %}'fonts-{{ package.name }}', {% endif %}{% endfor %})){% endif %}); {% for name, package in bower_assets %} {% if package.js is defined %} @@ -45,7 +49,7 @@ gulp.task('js-{{ package.name }}', function() { {% endif %} {% endfor %} // Provide JS from all libraries -gulp.task('js', [{% for name, package in bower_assets %}{% if package.js is defined %}'js-{{ package.name }}', {% endif %}{% endfor %}]); +gulp.task('js', {% if fontDefined %}gulp.series(gulp.parallel({% for name, package in bower_assets %}{% if package.js is defined %}'js-{{ package.name }}', {% endif %}{% endfor %})){% endif %}); // Pre-process CSS gulp.task('css', function() { @@ -72,8 +76,8 @@ gulp.task('css', function() { // Rerun the task when a file changes gulp.task('watch', function() { - gulp.watch(config.sassPath + '/**/*.scss', ['css']); + gulp.watch(config.sassPath + '/**/*.scss', gulp.parallel('css')); }); // Default task: run all other tasks in the correct order -gulp.task('default', ['fonts', 'js', 'css']); +gulp.task('default', gulp.series(gulp.parallel('fonts', 'js', 'css'))); diff --git a/templates/package.json b/templates/package.json index 114665f..d4c4db8 100644 --- a/templates/package.json +++ b/templates/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "autoprefixer": "^7.1.1", - "gulp": "^3.9.0", + "gulp": "^4.0.0", "gulp-if": "^2.0.0", "gulp-notify": "^2.2.0", "gulp-postcss": "^7.0.0", -- GitLab