View Source Unocss (unocss v0.61.5)

Unocss is an installer and runner for unocss.

profiles

Profiles

You can define multiple unocss profiles. By default, there is a profile called :default which you can configure its args, current directory and environment:

config :unocss,
  version: "0.61.5",
  default: [
    args: ~w(
      --config=unocss.config.js
      --input=css/app.css
      --output=../priv/static/assets/app.css
    ),
    cd: Path.expand("../assets", __DIR__),
  ]

unocss-configuration

Unocss configuration

There are two global configurations for the unocss application:

  • :version - the expected unocss version

  • :path - the path to find the unocss executable at. By default, it is automatically downloaded and placed inside the _build directory of your current app

Overriding the :path is not recommended, as we will automatically download and manage unocss for you. But in case you can't download it (for example, GitHub behind a proxy), you may want to set the :path to a configurable system location.

For instance, you can install unocss globally with npm:

$ npm install -g unocss

On Unix, the executable will be at:

NPM_ROOT/unocss/node_modules/unocss-TARGET/bin/unocss

On Windows, it will be at:

NPM_ROOT/unocss/node_modules/unocss-windows-(32|64)/unocss.exe

Where NPM_ROOT is the result of npm root -g and TARGET is your system target architecture.

Once you find the location of the executable, you can store it in a MIX_Unocss_PATH environment variable, which you can then read in your configuration file:

config :unocss, path: System.get_env("")

The first time this package is installed, a default unocss configuration will be placed in a new assets/unocss.config.js file. See the unocss documentation on configuration options.

Note: The stand-alone Unocss client bundles first-class unocss packages within the precompiled executable. For third-party Unocss plugin support, the node package must be used. See the unocss nodejs installation instructions if you require third-party plugin support.

The default unocss configuration includes Unocss variants for Phoenix LiveView specific lifecycle classes:

  • phx-no-feedback - applied when feedback should be hidden from the user
  • phx-click-loading - applied when an event is sent to the server on click while the client awaits the server response
  • phx-submit-loading - applied when a form is submitted while the client awaits the server response
  • phx-submit-loading - applied when a form input is changed while the client awaits the server response

Therefore, you may apply a variant, such as phx-click-loading:animate-pulse to customize unocss classes when Phoenix LiveView classes are applied.

Link to this section Summary

Functions

Returns the path to the executable.

Returns the version of the unocss executable.

Returns the configuration for the given profile.

Returns the configured unocss version.

The default URL to install Unocss from.

Installs, if not available, and then runs unocss.

Runs the given command with args.

Link to this section Functions

Returns the path to the executable.

The executable may not be available if it was not yet installed.

Returns the version of the unocss executable.

Returns {:ok, version_string} on success or :error when the executable is not available.

Returns the configuration for the given profile.

Returns nil if the profile does not exist.

Returns the configured unocss version.

The default URL to install Unocss from.

Link to this function

install(base_url \\ default_base_url())

View Source

Installs unocss with configured_version/0.

Link to this function

install_and_run(profile, args)

View Source

Installs, if not available, and then runs unocss.

Returns the same as run/2.

Link to this function

run(profile, extra_args)

View Source

Runs the given command with args.

The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call.