html build

This commit is contained in:
Ryan Burnette 2020-10-01 11:11:34 -04:00
parent eaa07f0cd0
commit dba6a47c16
5 changed files with 34 additions and 26 deletions

View File

@ -32,8 +32,8 @@ GIT_CLONE_URL=https://github.com/example/example
```bash ```bash
pushd html/ pushd html/
npm install npm ci
./scripts/development scripts/build
popd popd
``` ```

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
rm -rf dist
npx webpack --config webpack.production.js -p --colors
scripts/copy

5
html/scripts/copy Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
mkdir -p dist/templates
cp src/*.html dist/
cp src/templates/*.html dist/templates/

View File

@ -1,33 +1,35 @@
#!/usr/bin/env node #!/usr/bin/env node
'use strict'; "use strict";
var fs = require('fs'); var fs = require("fs");
var { exec } = require('child_process'); var { exec } = require("child_process");
var cmd = `rsync -av --exclude="**.js" --exclude="css/" --exclude="js/" src/ dist/`;
fs.watch( fs.watch(
'src', "src",
{ {
recursive: true recursive: true,
}, },
function (eventType, filename) { function (eventType, filename) {
//console.log(eventType, filename); if (filename.includes(".html")) {
if (filename.includes('.html')) { copy().then(function () {
rsync(); console.log("copied html");
});
} }
} }
); );
function rsync() { async function copy() {
exec( return new Promise(function (resolve) {
cmd, exec(
{ "scripts/copy",
path: process.env.PATH, {
cwd: process.cwd() path: process.env.PATH,
}, cwd: process.cwd(),
function (err, stdout, stderr) { },
console.log(stdout); function (err, stdout, stderr) {
} resolve();
); }
);
});
} }
rsync(); copy();

View File

@ -1,3 +0,0 @@
{
"email": "ryan.burnette@gmail.com"
}