Getting started

Installation

Add the CLI to a Jaspr project, generate the configuration and link the stylesheet.

Requirements

  • Dart 3.10 or newer.
  • A Jaspr 0.22 or 0.23 project (the generated CSS also works with plain HTML).

Add the dependency

Add jx_cli from pub.dev. This single package brings the jx command, the engine, the build_runner builder and the UI components:

dart pub add jx_cli

This adds to your file:

pubspec.yaml
dependencies:
  jx_cli: ^0.0.5

Global install

To use jx outside a project, install it as a global command with dart pub global activate jx_cli, then simply run jx build.

New Jaspr project

Projects created with jaspr create use Jaspr 0.23: dart pub add jx_cli installs jx_cli 0.0.4 or later, which supports it.

Create the configuration

jx init creates a commented jx.yaml file at the root of the project:

dart run jx_cli:jx init

The stylesheet is written to web/jx.css by default: Jaspr serves the web/ folder, so the file is available at /jx.css. Every option is described on the Configuration page.

Build

Run a single build, or let the CLI watch your sources during development:

dart run jx_cli:jx build
dart run jx_cli:jx build -w

Note

For production, add -m to minify the CSS. The preflight (reset stylesheet) is included by default.

Reference the generated file in your application's Document:

lib/main.server.dart
Document(
  title: 'My app',
  head: [
    link(rel: 'stylesheet', href: '/jx.css'),
  ],
  body: App(),
)