This is the sequence of operations constexpr.js compiler performs when it is invoked:
Render all the pages. For each page:
- Figure out its dependencies (css, images, etc).
- Snapshot the DOM state when the page finishes rendering.
- Kill the page.
- Write the DOM snapshots of each page as HTML files.
- Combine the dependency lists of all the pages into a single list.
- Copy dependencies to the output directory.
The compiler maintains a list of pages that it needs to process. In the beginning, this list contains only the
pages specified as entry points (
These invocations will append
Think of the generator page as a function that takes input in url query string/hash and produces the intended page as output. Try to make this a pure function.
Every page except the entry points will have a parent page which queued it for compilation. The queueing relationship between the pages will form a tree:
You can also use this option to compile only a small number of pages in your website, which might be useful if you have a huge website.
The motivation behind this feature is to decouple the structure of your output website from the filesystem. The design philosophy of constexpr.js goes against that of traditional static site generators which have a ton of implicit behavior, and plugins add more implicit behavior on top of that. In order to build a website with these SSGs, you need to understand a lot of such implicit behavior, which doesn't have any use outside the bounds of the given SSG.