From df8b3e88c82f0a108a524a4c52eaad6dcb2fbb91 Mon Sep 17 00:00:00 2001 From: horus_arch Date: Tue, 6 Dec 2016 21:32:36 +0100 Subject: Fügt erste Gulp-Tasks beim Build der Webseite hinu. Momentan funktioniert 'UnCSS' noch nicht so, wie es sollte. --- gospeladlershof.de/Makefile | 30 ++++++++++++++++++++---- gospeladlershof.de/gulpfile.js | 31 +++++++++++++++++++++++++ gospeladlershof.de/layouts/partials/header.tmpl | 30 +++++++++++++++--------- gospeladlershof.de/layouts/partials/js.tmpl | 10 ++++---- 4 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 gospeladlershof.de/gulpfile.js diff --git a/gospeladlershof.de/Makefile b/gospeladlershof.de/Makefile index 13e2ba2..23b7e6c 100644 --- a/gospeladlershof.de/Makefile +++ b/gospeladlershof.de/Makefile @@ -1,14 +1,23 @@ + all: build -build: - @./build.sh +build: clean + @HUGO_TEST=1 hugo --ignoreCache --log=true --logFile=../log/hugo.log --verbose=false 1>/dev/null \ + || ( echo "Failure building the site." && exit 1) + gulp concat + gulp uncss + @HUGO_READ_CONCAT=0 HUGO_TEST=0 \ + hugo --ignoreCache --log=true --logFile=../log/hugo.log --verbose=false \ + || ( echo "Failure building the site." && exit 1) + gulp minifyhtml + rm -rf public/css serve: server server: - hugo server + HUGO_TEST=0 hugo server -deploy: +deploy: build @if [ -d "/var/www/gospeladlershof.de/gospeladlershof.de/" ]; then \ rsync --delete -avz public/ /var/www/gospeladlershof.de/gospeladlershof.de/; \ else \ @@ -17,3 +26,16 @@ deploy: clean: $(RM) $(RMFLAGS) -r public/ + $(RM) $(RMFLAGS) static/concat.css + $(RM) $(RMFLAGS) -r static/gulp.css/ + +localbuild: clean + @HUGO_TEST=1 hugo --baseURL="http://192.168.178.68:3000/" --ignoreCache --log=true --logFile=../log/hugo.log --verbose=false 1>/dev/null \ + || ( echo "Failure building the site." && exit 1) + gulp concat + gulp uncss + @HUGO_READ_CONCAT=1 HUGO_TEST=0 \ + hugo --baseURL="http://192.168.178.68:3000/" --ignoreCache --log=true --logFile=../log/hugo.log --verbose=false \ + || ( echo "Failure building the site." && exit 1) + gulp minifyhtml + #rm -rf public/css diff --git a/gospeladlershof.de/gulpfile.js b/gospeladlershof.de/gulpfile.js new file mode 100644 index 0000000..ec97e58 --- /dev/null +++ b/gospeladlershof.de/gulpfile.js @@ -0,0 +1,31 @@ +var gulp = require('gulp'); +var cssnano = require('gulp-cssnano'); +var htmlmin = require('gulp-htmlmin'); +var uncss = require('gulp-uncss'); +var concat = require('gulp-concat'); + +gulp.task('concat', function() { + return gulp.src(['static/css/animate.min.css', 'static/css/bootstrap.min.css', 'static/css/magnific-popup.css', 'static/css/theme.css', 'static/css/chor.css']) + .pipe(concat('concat.css')) + .pipe(gulp.dest('./static/')); +}); + +gulp.task('uncss', function() { + return gulp.src('static/concat.css') + .pipe(uncss({ + html: ['public/*.html', 'public/impressum/*.html'], + ignore: ['.text-right', '.text-left', '.affix', '.navbar-default.affix'] + })) + .pipe(cssnano()) + .pipe(gulp.dest('./static/gulp.css')); +}); + +gulp.task('minifyhtml', function() { + gulp.src('public/*.html') + .pipe(htmlmin({collapseWhitespace: true})) + .pipe(gulp.dest('public/')); + return gulp.src('public/impressum/*.html') + .pipe(htmlmin({collapseWhitespace: true})) + .pipe(gulp.dest('public/impressum/')); +}); + diff --git a/gospeladlershof.de/layouts/partials/header.tmpl b/gospeladlershof.de/layouts/partials/header.tmpl index 8ff6286..4e68ffe 100644 --- a/gospeladlershof.de/layouts/partials/header.tmpl +++ b/gospeladlershof.de/layouts/partials/header.tmpl @@ -20,7 +20,8 @@ {{.Title}} {{end}} -{{ if not .Site.Params.cssmin}} +{{$tmp := getenv "HUGO_TEST"}} +{{if eq $tmp "1"}} @@ -37,16 +38,16 @@ {{ else }} - -{{ end }} - - - - {{if .Site.Params.enablepiwik}} + {{$read := getenv "HUGO_READ_CONCAT"}} + {{if eq $read "1"}} + + {{else}} + + {{end}} + - {{end}} +{{ end }} + + + + diff --git a/gospeladlershof.de/layouts/partials/js.tmpl b/gospeladlershof.de/layouts/partials/js.tmpl index 4cdcde9..f765f4b 100644 --- a/gospeladlershof.de/layouts/partials/js.tmpl +++ b/gospeladlershof.de/layouts/partials/js.tmpl @@ -1,4 +1,9 @@ -{{if not .Site.Params.jsmin}} + +{{$tmp := getenv "HUGO_TEST-BL"}} +{{if eq $tmp "1"}} + +{{else}} +{{end}} @@ -13,9 +18,6 @@ -{{else}} - -{{end}} -- cgit v1.2.3