From dba6a47c16cc506a1ec8a724f6e08189c41c9a14 Mon Sep 17 00:00:00 2001 From: Ryan Burnette Date: Thu, 1 Oct 2020 11:11:34 -0400 Subject: [PATCH] html build --- README.md | 4 ++-- html/scripts/build | 4 ++++ html/scripts/copy | 5 +++++ html/scripts/watch | 44 ++++++++++++++++++++------------------- html/src/api/auth/me.json | 3 --- 5 files changed, 34 insertions(+), 26 deletions(-) create mode 100755 html/scripts/copy delete mode 100644 html/src/api/auth/me.json diff --git a/README.md b/README.md index af00f98..3bd5311 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ GIT_CLONE_URL=https://github.com/example/example ```bash pushd html/ -npm install -./scripts/development +npm ci +scripts/build popd ``` diff --git a/html/scripts/build b/html/scripts/build index e69de29..9e85838 100755 --- a/html/scripts/build +++ b/html/scripts/build @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +rm -rf dist +npx webpack --config webpack.production.js -p --colors +scripts/copy diff --git a/html/scripts/copy b/html/scripts/copy new file mode 100755 index 0000000..73cf95b --- /dev/null +++ b/html/scripts/copy @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +mkdir -p dist/templates +cp src/*.html dist/ +cp src/templates/*.html dist/templates/ diff --git a/html/scripts/watch b/html/scripts/watch index 9c06438..10703f8 100755 --- a/html/scripts/watch +++ b/html/scripts/watch @@ -1,33 +1,35 @@ #!/usr/bin/env node -'use strict'; +"use strict"; -var fs = require('fs'); -var { exec } = require('child_process'); +var fs = require("fs"); +var { exec } = require("child_process"); -var cmd = `rsync -av --exclude="**.js" --exclude="css/" --exclude="js/" src/ dist/`; fs.watch( - 'src', + "src", { - recursive: true + recursive: true, }, function (eventType, filename) { - //console.log(eventType, filename); - if (filename.includes('.html')) { - rsync(); + if (filename.includes(".html")) { + copy().then(function () { + console.log("copied html"); + }); } } ); -function rsync() { - exec( - cmd, - { - path: process.env.PATH, - cwd: process.cwd() - }, - function (err, stdout, stderr) { - console.log(stdout); - } - ); +async function copy() { + return new Promise(function (resolve) { + exec( + "scripts/copy", + { + path: process.env.PATH, + cwd: process.cwd(), + }, + function (err, stdout, stderr) { + resolve(); + } + ); + }); } -rsync(); +copy(); diff --git a/html/src/api/auth/me.json b/html/src/api/auth/me.json deleted file mode 100644 index ca8828c..0000000 --- a/html/src/api/auth/me.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "email": "ryan.burnette@gmail.com" -}