2024-08-11 13:34:30 +00:00
|
|
|
const assproc = require('@railcomm/assproc');
|
|
|
|
const { join: pathJoin } = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
const exec = require('util').promisify(require('child_process').exec);
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const config = JSON.parse(fs.readFileSync(pathJoin(__dirname, 'config.json')));
|
|
|
|
const isDebug = fs.existsSync(pathJoin(__dirname, '.debug'));
|
|
|
|
|
|
|
|
const env = {
|
|
|
|
root: __dirname,
|
|
|
|
source: pathJoin(__dirname, 'src'),
|
|
|
|
public: pathJoin(__dirname, 'public'),
|
|
|
|
debug: isDebug,
|
|
|
|
swc: {
|
2024-08-11 21:01:28 +00:00
|
|
|
es: 'es2021',
|
2024-08-11 13:34:30 +00:00
|
|
|
},
|
|
|
|
vars: {
|
|
|
|
html: {}, // BUG: if this isn't definited prior, assproc will fail
|
|
|
|
build: {
|
|
|
|
DEBUG: isDebug,
|
|
|
|
IPV4_LOOKUP: config.ipv4_lookup,
|
|
|
|
IPV6_LOOKUP: config.ipv6_lookup,
|
|
|
|
GIT_HASH: (await exec('git log --pretty="%H" -n1 HEAD')).stdout.trim(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const tasks = {
|
|
|
|
js: [
|
|
|
|
{ source: 'ipaddr.js', target: '/assets', name: 'ipaddr.{hash}.js', vars: { html: ':source' } },
|
|
|
|
],
|
|
|
|
css: [
|
|
|
|
{ source: 'ipaddr.css', target: '/assets', name: 'ipaddr.{hash}.css', vars: { html: ':source' } },
|
|
|
|
],
|
|
|
|
html: [
|
|
|
|
{ source: 'index.html', target: '/', name: 'index.html', template: 'html' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
await assproc.process(env, tasks);
|
|
|
|
})();
|