From 9488becd81d747ab0324fe2ed25c4433875f1a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 13 Sep 2017 01:08:34 +0200 Subject: [PATCH] some build script tuning, exclude demo script for prod build --- _build_css.sh | 8 +++++++- _build_js.sh | 16 ++++++++++++++-- js/term_conn.js | 15 +++++++++++---- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/_build_css.sh b/_build_css.sh index 1cfa157..8679569 100755 --- a/_build_css.sh +++ b/_build_css.sh @@ -3,5 +3,11 @@ source "_build_common.sh" echo 'Building CSS...' +if [[ $ESP_PROD ]]; then + stylearg=compressed +else + stylearg=expanded +fi + mkdir -p out/css -npm run sass -- --output-style compressed sass/app.scss "out/css/app.$FRONT_END_HASH.css" +npm run sass -- --output-style ${stylearg} sass/app.scss "out/css/app.$FRONT_END_HASH.css" diff --git a/_build_js.sh b/_build_js.sh index f580f9b..7122d5e 100755 --- a/_build_js.sh +++ b/_build_js.sh @@ -5,8 +5,20 @@ mkdir -p out/js echo 'Generating lang.js...' php ./dump_js_lang.php +if [[ $ESP_DEMO ]]; then + demofile=js/demo.js +else + demofile= +fi + echo 'Processing JS...' -npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" --source-maps js/lib \ +if [[ $ESP_PROD ]]; then + smarg= +else + smarg=--source-maps +fi + +npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" ${smarg} js/lib \ js/lib/chibi.js \ js/lib/keymaster.js \ js/lib/polyfills.js \ @@ -14,7 +26,7 @@ npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" --source-maps js/lib \ js/modal.js \ js/notif.js \ js/appcommon.js \ - js/demo.js \ + $demofile \ js/lang.js \ js/wifi.js \ js/term_* \ diff --git a/js/term_conn.js b/js/term_conn.js index 65506d7..955fee1 100644 --- a/js/term_conn.js +++ b/js/term_conn.js @@ -67,7 +67,11 @@ window.Conn = function (screen) { function doSend (message) { if (_demo) { - window.demoInterface.input(message) + if (typeof demoInterface !== 'undefined') { + demoInterface.input(message) + } else { + console.log(`TX: ${JSON.stringify(message)}`) + } return true // Simulate success } if (xoff) { @@ -90,9 +94,12 @@ window.Conn = function (screen) { function init () { if (window._demo) { - console.log('Demo mode!') - demoInterface.init(screen) - showPage() + if (typeof demoInterface === 'undefined') { + alert('Demoing non-demo demo!') // this will catch mistakes when deploying to the website + } else { + demoInterface.init(screen) + showPage() + } return }