scmorrison / uzu

Uzu is a static site generator with built-in web server, file modification watcher, live reload, i18n, themes, multi-page support, inject external data via local Raku module, and external pre/post command execution.
Artistic License 2.0
36 stars 1 forks source link

Incremental build output #12

Closed evanmiller closed 5 years ago

evanmiller commented 7 years ago

For large builds it would be nice if HTML files were written to disk as they became available, rather than all at once. It would also be convenient if pages were compiled from newest to oldest mtime, so that templates that I'm working on would be compiled (and available for inspection) first.

scmorrison commented 7 years ago

Hi @evanmiller, I have taken an initial step in this direction. The issue with the way the sorting is implemented at the moment is that even though the templates are now sorted by modified timestamp in the initial search, these end up in a hash and order isn't guaranteed in the loop that processes them. I will eventually add these to a sortable list before processing. These are now correctly sorted before rendering.

Also, I have implemented a first pass at a render queue construct. I have noticed a slight reduction in build times in my tests. Eventually I will start tracking all template modified timestamps and make some smarter decisions about what to render and ways to avoid re-rendering files that have no template modifications (layout, partials, or page).

For now, please test this latest update and let me know if you run into any issues.

Thanks,
Sam

evanmiller commented 7 years ago

Thanks. Works fine, I'm seeing an improvement as well, esp. with system time. I'd still like to see the HTML files appear incrementally as my total build time is still over 5 minutes.

Smart re-rendering or anything else that you can do to cut down build time would be very much appreciated. I'm now using Uzu in production on my personal website (evanmiller.org) with 70+ templates. At this point I have to test changes directly in the build/ folder and then port changes back over to the template files. Not ideal, but I'll manage for now.

Keep up the good work!

scmorrison commented 7 years ago

Nice, thanks for the positive feedback. I really do appreciate your input and ideas. Expect some progress on partial builds within the next few weeks.

scmorrison commented 7 years ago

@evanmiller, i have added a modification that changes the build behavior.

  1. The build directory is no longer cleared before every build, but you can run uzu --clear build to have uzu use the old behavior. Also added uzu clear.
  2. Uzu will no longer rebuild everything for every build. It will only rebuild a page if the page's layout, template, or any partial template have been modified. So this should speed up builds if you are only adding / modifying page templates.
  3. If you delete static assets from public/ or themes/**/assets/ these will not be deleted from build/ until you do a full rebuild (uzu --clear build).

The next target will be the piecemeal builds and limiting partial template renders to only partials that are included in the layout, page, or referenced from page/layout partial templates.

Please let me know if the new modifications break anything for you.

evanmiller commented 7 years ago

@scmorrison, this change is very welcome. It will definitely speed up my development when I am working on new pages.

One issue I encountered is that modifications to i18n do not force the affected template files to be rebuilt.

scmorrison commented 7 years ago

@evanmiller, good timing. i just committed a fix for the i18n timestamps. Those should also trigger a rebuild now.