-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.mjs
More file actions
39 lines (33 loc) · 1.57 KB
/
Copy pathrun.mjs
File metadata and controls
39 lines (33 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* 02 — build-pipeline
*
* The full pipeline in one call: a shared brand <layout> (which itself
* pulls in the shared header and footer <include>s), a linked SCSS theme,
* and CSS inlining — everything transform() alone doesn't do.
*
* NODE EXCEPTION: the WASM binding has no filesystem access, so it cannot
* resolve <layout>/<include>/<link href="*.scss">. This example shells out
* to the `inky` CLI (`inky build`) as a subprocess instead — see
* lib/cli.mjs and this repo's README "Node exception". The template and
* shared fixtures are identical to the PHP reference; only the driver
* differs.
*/
import path from "node:path";
import { fileURLToPath } from "node:url";
import { inkyExample } from "../../bootstrap.mjs";
import { buildFile } from "../../lib/cli.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const dist = inkyExample("02-build-pipeline");
// base_path (this file's own directory, examples/02-build-pipeline/) anchors
// every relative <layout>/<include>/<link> path in the template AND in
// anything it includes — see SUITE.md "Runtime requirements". The CLI's
// single-file build derives base_path from the input file's own parent
// directory, so passing the real email.inky path (rather than piping via
// stdin) reproduces exactly that.
const input = path.join(__dirname, "email.inky");
const output = path.join(dist, "email.html");
const { html, warnings } = buildFile(input, { output });
for (const warning of warnings) {
console.error(`warning: ${warning}`);
}
console.log(`email.html: ${Buffer.byteLength(html)} bytes`);