I would like to suggest adding a
For example, receive current version information directly from Git, or conditionally rendering material (much like an #ifdef). There are countless possibilities.
Command-line definitions could be accessed via the `Prince` object or perhaps some object embedded in `window`.
Example:
Similar approaches:
- Give access to environment variables in JS (similar to Node.JS `process.env`, could be `Prince.env`), making the whole thing trivial;
- Accept a `key=value` file ("environment file") with the same semantics, maybe `--env-file`.
I am currently emulating this behavior by producing a JSON file in compile-time with required build time definitions and loading it via `XMLHttpRequest` with a local webserver (since XHR doesn't support local file loads), which is very cumbersome.
What do you think about this?
Thanks!
--define=property=val
command-line option, which is useful for communicating build environment information to the document, for further processing with JavaScript.For example, receive current version information directly from Git, or conditionally rendering material (much like an #ifdef). There are countless possibilities.
Command-line definitions could be accessed via the `Prince` object or perhaps some object embedded in `window`.
Example:
# command-line:
# --define=rev=$(git describe --always)
# html:
<footer><div id=rev>rev. </div></footer>
# js:
const rev = document.getElementById("rev");
const version = document.createElement("span");
version.textContent = Prince.defines.rev;
rev.appendChild(version);
Similar approaches:
- Give access to environment variables in JS (similar to Node.JS `process.env`, could be `Prince.env`), making the whole thing trivial;
- Accept a `key=value` file ("environment file") with the same semantics, maybe `--env-file`.
I am currently emulating this behavior by producing a JSON file in compile-time with required build time definitions and loading it via `XMLHttpRequest` with a local webserver (since XHR doesn't support local file loads), which is very cumbersome.
What do you think about this?
Thanks!