👷 Build system works

This commit is contained in:
Dan Jones 2022-12-21 15:57:06 -06:00
commit 4addbac3fb
6 changed files with 37 additions and 2 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
package-lock.json package-lock.json
node_modules/ node_modules/
*.~undo-tree~

View file

@ -0,0 +1,5 @@
build/index.html: build/style.css index.html config.toml compile.js
node compile.js
build/style.css: scss/style.scss
npx sass $< $@

View file

@ -0,0 +1,20 @@
const { parse } = require('@ltd/j-toml');
const { render } = require('mustache');
const { readFile, writeFile } = require('node:fs/promises');
const { resolve } = require('node:path');
async function compile() {
const confPath = resolve('./config.toml');
const confToml = await readFile(confPath, { encoding: 'utf8' });
const config = parse(confToml);
const tempPath = resolve('./index.html');
const template = await readFile(tempPath, { encoding: 'utf8' });
const out = render(template, config);
const outPath = resolve('./build/index.html');
await writeFile(outPath, out);
}
compile();

View file

@ -0,0 +1 @@
title = "Dan Jones's Links"

View file

@ -0,0 +1,8 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>{{title}}</title>
</head>
<body></body>
</html>

View file

@ -16,8 +16,8 @@
"author": "Dan Jones", "author": "Dan Jones",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@ltd/j-toml": "^1.36.0",
"mustache": "^4.2.0", "mustache": "^4.2.0",
"sass": "^1.57.1", "sass": "^1.57.1"
"toml-nodejs": "^0.2.0"
} }
} }