From 2207d3be5526fcc69cbf71974e9fca53468ef535 Mon Sep 17 00:00:00 2001 From: leopuleo Date: Tue, 24 Oct 2017 23:35:55 +0200 Subject: [PATCH] New Gulp task to move all the fonts in a flattened directory inside dist --- gulpfile.babel.js | 16 +++++++++++++--- package.json | 1 + src/fonts/.keep | 0 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/fonts/.keep diff --git a/gulpfile.babel.js b/gulpfile.babel.js index df7da2d..807bdc5 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -2,6 +2,7 @@ import gulp from "gulp"; import {spawn} from "child_process"; import hugoBin from "hugo-bin"; import gutil from "gulp-util"; +import flatten from "gulp-flatten"; import postcss from "gulp-postcss"; import cssImport from "postcss-import"; import cssnext from "postcss-cssnext"; @@ -21,8 +22,8 @@ gulp.task("hugo", (cb) => buildSite(cb)); gulp.task("hugo-preview", (cb) => buildSite(cb, hugoArgsPreview)); // Build/production tasks -gulp.task("build", ["css", "js"], (cb) => buildSite(cb, [], "production")); -gulp.task("build-preview", ["css", "js"], (cb) => buildSite(cb, hugoArgsPreview, "production")); +gulp.task("build", ["css", "js", "fonts"], (cb) => buildSite(cb, [], "production")); +gulp.task("build-preview", ["css", "js", "fonts"], (cb) => buildSite(cb, hugoArgsPreview, "production")); // Compile CSS with PostCSS gulp.task("css", () => ( @@ -47,8 +48,16 @@ gulp.task("js", (cb) => { }); }); +// Move all fonts in a flattened directory +gulp.task('fonts', () => ( + gulp.src("./src/fonts/**/*") + .pipe(flatten()) + .pipe(gulp.dest("./dist/fonts")) + .pipe(browserSync.stream()) +)); + // Development server with browsersync -gulp.task("server", ["hugo", "css", "js"], () => { +gulp.task("server", ["hugo", "css", "js", "fonts"], () => { browserSync.init({ server: { baseDir: "./dist" @@ -56,6 +65,7 @@ gulp.task("server", ["hugo", "css", "js"], () => { }); watch("./src/js/**/*.js", () => { gulp.start(["js"]) }); watch("./src/css/**/*.css", () => { gulp.start(["css"]) }); + watch("./src/fonts/**/*", () => { gulp.start(["fonts"]) }); watch("./site/**/*", () => { gulp.start(["hugo"]) }); }); diff --git a/package.json b/package.json index 250f256..732442f 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "file-loader": "^0.11.1", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", + "gulp-flatten": "^0.3.1", "gulp-postcss": "^6.1.1", "gulp-util": "^3.0.7", "gulp-watch": "^4.3.11", diff --git a/src/fonts/.keep b/src/fonts/.keep new file mode 100644 index 0000000..e69de29