Skip to content

feat(cli): inline whole directories - #669

Merged
cossssmin merged 2 commits into
masterfrom
feat/cli-directories
Sep 24, 2026
Merged

cossssmin merged 2 commits into
masterfrom
feat/cli-directories

Conversation

@cossssmin

Copy link
Copy Markdown
Collaborator

Closes #337, closes #374

Note: builds on #668 (CLI test coverage), so this shows that commit too until #668 is merged.

The CLI can now inline a whole directory:

juice src dist

It's detected automatically when the input is a directory (no new flag). Every .html and .htm file in it, including subdirectories, is inlined and written to the same relative path in the output directory.

  • all CLI options apply to every file (--css, --options-file, --web-resources-*)
  • relative <link>s resolve against each file's own directory
  • if the output directory is inside the input one (juice src src/dist), it's skipped, so outputs never get re-inlined on the next run
  • if a file fails, it's reported with its path, the rest are still processed, and the CLI exits with 1 at the end
  • a directory input without an output directory is an error, and - (stdin/stdout) can't be combined with directories

One thing worth pointing out: juiceFile fills in webResources.relativeTo on the options object it's given, only if it isn't set yet. Sharing one options object across files would make every file resolve its links against the first file's directory, so each file gets its own copy (there's a test with nested <link>s that fails without it).

Performance

200 files (12KB each, remote resources off), same output:

Time
juice src dist 842ms
find src -name '*.html' | xargs -P 16 juice ... (the workaround from #374) 3,046ms

Each separate juice process pays around half a second of Node startup + imports, so doing it in one process is ~3.6x faster, even with 16 processes in parallel on a 24-core machine.

Also documented in the README's CLI section, and the --help argument descriptions mention directories.

🤖 Generated with Claude Code

cossssmin and others added 2 commits September 24, 2026 18:04
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@cossssmin
cossssmin merged commit d2350d3 into master Sep 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for juicing entire directories [CLI] Support unnamed recursive inlining

1 participant