mix live_flow.gen.elk (LiveFlow v0.3.2)

Copy Markdown View Source

Adds ELK (elkjs) to your app's JavaScript, for the client-side auto layout (LiveFlow.Layout.prepare_layout_data/2 pushed as lf:layout_data, or JS.dispatch("lf:auto-layout")).

ELK is optional because it adds about 1.6 MB to the bundle. The server-side layouts (LiveFlow.Layout.tree/2, force/2) and the JS tree layout (prepare_tree_layout_data/2) don't need it.

$ mix live_flow.gen.elk

The task:

  1. copies elkjs to assets/vendor/elk.bundled.cjs

  2. registers it in assets/js/app.js:

    import ELK from "../vendor/elk.bundled.cjs"
    import {registerElk} from "live_flow"
    registerElk(ELK)

Running it again is safe: an existing vendor file is kept (unless --force) and app.js is changed only once.

Options

  • --assets - the assets directory (default: assets)
  • --entry - the JS entry point, relative to the assets directory (default: js/app.js)
  • --force - overwrite vendor/elk.bundled.cjs if it exists
  • --no-import - only copy the file, leave the entry point untouched

To use the npm package instead, run npm install elkjs --prefix assets and register import ELK from "elkjs/lib/elk.bundled.js".