From b7d7f2fc3b260707489edd419776db25ddcf30ca Mon Sep 17 00:00:00 2001 From: Nils Windisch Date: Thu, 8 Mar 2018 09:08:42 +0100 Subject: [PATCH] REFACTOR tooling --- .env | 1 + .gitignore | 2 +- bin/build.sh | 13 +++++++ bin/dev.sh | 6 ++- bin/dist.sh | 12 ------ bin/jekyll-build--dev--netlify.sh | 14 ------- bin/jekyll-build--dev.sh | 6 --- bin/{scss-build--dev.sh => jekyll-build.sh} | 2 +- bin/lib.sh | 28 +++++--------- bin/lib/image.sh | 1 + bin/lib/jekyll.sh | 37 +++++++------------ bin/netlify.sh | 12 ------ bin/{predist.sh => prebuild.sh} | 4 +- bin/predev.sh | 2 + bin/prenetlify.sh | 10 ----- bin/{scss-watch--dev.sh => scss-build.sh} | 2 +- ...fig_netlify.yml => jekyll_config_build.yml | 2 +- jekyll_config_dist.yml | 2 - package.json | 10 ++--- 19 files changed, 55 insertions(+), 111 deletions(-) create mode 100644 .env create mode 100755 bin/build.sh delete mode 100755 bin/dist.sh delete mode 100755 bin/jekyll-build--dev--netlify.sh delete mode 100755 bin/jekyll-build--dev.sh rename bin/{scss-build--dev.sh => jekyll-build.sh} (82%) delete mode 100755 bin/netlify.sh rename bin/{predist.sh => prebuild.sh} (79%) delete mode 100755 bin/prenetlify.sh rename bin/{scss-watch--dev.sh => scss-build.sh} (82%) rename jekyll_config_netlify.yml => jekyll_config_build.yml (63%) delete mode 100644 jekyll_config_dist.yml diff --git a/.env b/.env new file mode 100644 index 0000000..1ee0160 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +export MODE="production" diff --git a/.gitignore b/.gitignore index fcbc9d9..2212f2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ assets/css assets/img/optimized -dist +build jekyll/assets/css jekyll/assets/img node_modules diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..5929b77 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# shellcheck disable=SC1091 + +source ./.env +source ./bin/lib.sh + +log "🎬 Build start" + +imgBuild +scssBuild +jekyllBuild + +log "🏁 Build done" diff --git a/bin/dev.sh b/bin/dev.sh index 7032f02..ecc39bb 100755 --- a/bin/dev.sh +++ b/bin/dev.sh @@ -1,6 +1,10 @@ #!/bin/bash # shellcheck disable=SC1091 +source ./.env +export MODE="development" source ./bin/lib.sh -browsersyncStart & imgWatch & scssWatchDev & jekyllWatchDev +log "🎬 DEV start" + +browsersyncStart & imgWatch & scssWatch & jekyllWatch diff --git a/bin/dist.sh b/bin/dist.sh deleted file mode 100755 index 5ab0ae3..0000000 --- a/bin/dist.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091 - -source ./bin/lib.sh - -log "🎬 Dist start" - -imgBuild -scssBuildDist -jekyllBuildDist - -log "🏁 Dist done" diff --git a/bin/jekyll-build--dev--netlify.sh b/bin/jekyll-build--dev--netlify.sh deleted file mode 100755 index 8ab9cd1..0000000 --- a/bin/jekyll-build--dev--netlify.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# shellcheck disable=SC1091 -source ./bin/lib.sh - -if [ -n "$1" ]; then - BY="📦 $1" -fi - -log "🏗 Jekyll Build [DEV, NETLIFY] $BY" - -bundle exec \ - jekyll build \ - --config jekyll_config_base.yml,jekyll_config_netlify.yml diff --git a/bin/jekyll-build--dev.sh b/bin/jekyll-build--dev.sh deleted file mode 100755 index 9d3806c..0000000 --- a/bin/jekyll-build--dev.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091 - -source ./bin/lib.sh - -jekyllBuildDev diff --git a/bin/scss-build--dev.sh b/bin/jekyll-build.sh similarity index 82% rename from bin/scss-build--dev.sh rename to bin/jekyll-build.sh index 1a9bb2b..a0287c7 100755 --- a/bin/scss-build--dev.sh +++ b/bin/jekyll-build.sh @@ -3,4 +3,4 @@ source ./bin/lib.sh -scssBuildDev +jekyllBuild diff --git a/bin/lib.sh b/bin/lib.sh index 4172162..aef7108 100755 --- a/bin/lib.sh +++ b/bin/lib.sh @@ -31,9 +31,9 @@ function cssCopyToJekyll() { cp ./assets/css/style.css.map ./jekyll/assets/css/style.css.map } -function distCleanup() { - log "🗑️ DIST Clean-Up" - rm -rf dist +function buildCleanup() { + log "🗑️ Build Clean-Up" + rm -rf build } function log() { @@ -46,15 +46,16 @@ function logCleanup() { log "🗑️ LOG Clean-Up" } -function scssWatchDev() { +function scssWatch() { log "😳 SCSS watch" ./node_modules/.bin/nodemon \ -e scss \ --watch assets/scss \ - -x ./bin/scss-build--dev.sh + --verbose \ + -x ./bin/scss-build.sh } -function scssBuildDev() { +function scssBuild() { scssProcess postcssPrefix postcssCalc @@ -62,18 +63,9 @@ function scssBuildDev() { postcssObjectfit postcssSelectornot postcssCustomproperties - cssCopyToJekyll -} - -function scssBuildDist() { - scssProcess - postcssPrefix - postcssCalc - postcssFontvalues - postcssObjectfit - postcssSelectornot - postcssCustomproperties - postcssO + if [ "$MODE" = "production" ]; then + postcssO + fi cssCopyToJekyll } diff --git a/bin/lib/image.sh b/bin/lib/image.sh index 2e5af49..cf4a974 100755 --- a/bin/lib/image.sh +++ b/bin/lib/image.sh @@ -54,6 +54,7 @@ function imgWatch() { ./node_modules/.bin/nodemon \ -e jpeg,jpg,png,svg,gif \ --watch assets/img/original \ + --verbose \ -x "./bin/img-build.sh" } diff --git a/bin/lib/jekyll.sh b/bin/lib/jekyll.sh index e20fc8f..7ffbfef 100755 --- a/bin/lib/jekyll.sh +++ b/bin/lib/jekyll.sh @@ -2,37 +2,28 @@ # shellcheck disable=SC2154 # shellcheck disable=SC2086 -function jekyllBuildDist() { - log "🏗️ JEKYLL build [DIST]" - bundle exec \ - jekyll build \ - --config jekyll_config_base.yml,jekyll_config_dist.yml -} - -function jekyllBuildNetlify() { - log "🏗️ JEKYLL build [NETLIFY]" - bundle exec \ - jekyll build \ - --config jekyll_config_base.yml,jekyll_config_netlify.yml -} - -function jekyllBuildDev() { - log "🏗️ JEKYLL build [DEV]" - bundle exec \ - jekyll build \ - --config jekyll_config_base.yml -} - function jekyllCleanup() { log "🗑️ JEKYLL Clean-Up" rm -r ./jekyll/assets/img/* rm -r ./jekyll/assets/css/* } -function jekyllWatchDev() { +function jekyllWatch() { log "😳 JEKYLL watch" ./node_modules/.bin/nodemon \ -e md,html,css,js,png,jpg,jpeg,svg \ --watch jekyll \ - -x "./bin/jekyll-build--dev.sh; ./bin/browsersync-reload.sh;" + --verbose \ + -x "./bin/jekyll-build.sh; ./bin/browsersync-reload.sh;" +} + +function jekyllBuild() { + log "🏗️ JEKYLL build" + JEKYLL_CONF="jekyll_config_base.yml" + if [ "$MODE" = "production" ]; then + JEKYLL_CONF=$JEKYLL_CONF",jekyll_config_build.yml" + fi + bundle exec \ + jekyll build \ + --config $JEKYLL_CONF } diff --git a/bin/netlify.sh b/bin/netlify.sh deleted file mode 100755 index c979527..0000000 --- a/bin/netlify.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091 - -source ./bin/lib.sh - -log "🎬 Dist start" - -imgBuild -scssBuildDist -jekyllBuildNetlify - -log "🏁 Dist done" diff --git a/bin/predist.sh b/bin/prebuild.sh similarity index 79% rename from bin/predist.sh rename to bin/prebuild.sh index 0cbfe76..8b7659c 100755 --- a/bin/predist.sh +++ b/bin/prebuild.sh @@ -4,7 +4,7 @@ source ./bin/lib.sh logCleanup -distCleanup +buildCleanup jekyllCleanup imgCleanup -mkdir dist +mkdir build diff --git a/bin/predev.sh b/bin/predev.sh index cb24a76..4533444 100755 --- a/bin/predev.sh +++ b/bin/predev.sh @@ -1,6 +1,8 @@ #!/bin/bash # shellcheck disable=SC1091 +source ./.env +MODE=development source ./bin/lib.sh logCleanup diff --git a/bin/prenetlify.sh b/bin/prenetlify.sh deleted file mode 100755 index 0cbfe76..0000000 --- a/bin/prenetlify.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091 - -source ./bin/lib.sh - -logCleanup -distCleanup -jekyllCleanup -imgCleanup -mkdir dist diff --git a/bin/scss-watch--dev.sh b/bin/scss-build.sh similarity index 82% rename from bin/scss-watch--dev.sh rename to bin/scss-build.sh index 1a9bb2b..5276928 100755 --- a/bin/scss-watch--dev.sh +++ b/bin/scss-build.sh @@ -3,4 +3,4 @@ source ./bin/lib.sh -scssBuildDev +scssBuild diff --git a/jekyll_config_netlify.yml b/jekyll_config_build.yml similarity index 63% rename from jekyll_config_netlify.yml rename to jekyll_config_build.yml index 48c11bb..ad916fe 100644 --- a/jekyll_config_netlify.yml +++ b/jekyll_config_build.yml @@ -1,2 +1,2 @@ title: "GRO DSpaceCRIS Design 2017" -destination: "dist" +destination: "build" diff --git a/jekyll_config_dist.yml b/jekyll_config_dist.yml deleted file mode 100644 index 8114cf7..0000000 --- a/jekyll_config_dist.yml +++ /dev/null @@ -1,2 +0,0 @@ -title: "GRO DSpaceCRIS Design 2017 [DEV]" -destination: "dist" diff --git a/package.json b/package.json index c3ae737..32109b7 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,7 @@ "name": "Mockup-Template", "version": "0.0.1", "description": "Lorem ipsum dolor sit amut.", - "contributors": [ - "Nils Windisch" - ], + "contributors": ["Nils Windisch"], "homepage": "https://gro-dspacecris-design-2017.netlify.com/", "author": "Nils Windisch ", "devDependencies": { @@ -80,10 +78,8 @@ } }, "scripts": { - "predist": "./bin/predist.sh", - "dist": "./bin/dist.sh", - "prenetlify": "./bin/prenetlify.sh", - "netlify": "./bin/netlify.sh", + "prebuild": "./bin/prebuild.sh", + "build": "./bin/build.sh", "predev": "./bin/predev.sh", "dev": "./bin/dev.sh", "sassdoc": "./bin/sassdoc.sh"