Engine and CLI

Automatic builds

With the JX builder, jaspr serve and jaspr build write the stylesheet themselves.

The builder in jx_cli plugs JX into build_runner, the build system Jaspr already runs. There is no second terminal and no jx build -w to keep alive: the stylesheet is rebuilt on every save, together with your components.

Installation

It ships with jx_cli and is off by default. Turn it on in build.yaml:

build.yaml
targets:
  $default:
    builders:
      jx_cli:jx_css:
        enabled: true
jaspr serve

Link the stylesheet once, in your Document:

Document(
  head: [link(rel: 'stylesheet', href: '/jx.css')],
  body: App(),
)

Configuration

The builder reads the same jx.yaml as the CLI: content, extensions, exclude, packages, minify, reset, dark_mode and theme. output is ignored: the file is always served at /jx.css.

Note

jx.yaml is read when the build starts. To have changes picked up while jaspr serve runs, add it to the target sources in build.yaml.

build.yaml
targets:
  $default:
    sources:
      include: [$package$, lib/**, web/**, jx.yaml, pubspec.yaml]

Minify in release

build.yaml
targets:
  $default:
    builders:
      jx_cli:jx_css:
        enabled: true
        release_options:
          minify: true

Moving from jx build

  • Delete the web/jx.css written by the CLI: build_runner refuses to overwrite a source file.
  • Remove jx build from your scripts. jx migrate and jx init stay useful.