SassFX is a pure Java 17 Sass compiler. It compiles SCSS, indented Sass, and plain CSS to standard CSS, validated JavaFX CSS, or JavaFX binary stylesheets (BSS).
SassFX does not invoke Dart Sass or Node.js, use FFI, load JavaFX, or ship native libraries.
- Pure Java compiler and frontends targeting Java 17.
- Standard CSS, JavaFX CSS, and JavaFX BSS output.
- JavaFX 8 through 27 target models and BSS versions 5 through 9.
- Java API with source maps, diagnostics, custom importers, and custom functions.
- Cacheable Gradle plugin for compiling project resources.
- Command-line and Embedded Sass Protocol frontends.
| Module | Purpose |
|---|---|
sassfx-core |
Compiler and reusable Java API |
sassfx-cli |
Standalone command-line application |
sassfx-embedded |
Embedded Sass Protocol endpoint for host tools |
sassfx-gradle-plugin |
Gradle build integration |
The core artifact is a regular library JAR. The CLI, Embedded endpoint, and Gradle plugin are published as self-contained JARs with relocated runtime dependencies.
Apply the plugin and configure the desired output target:
plugins {
java
id("org.glavo.sassfx") version "<version>"
}
sassfx {
target.set("css/javafx@21")
style.set("compressed")
loadPaths.from(layout.projectDirectory.dir("src/shared/scss"))
}By default, compileScss compiles entrypoints under src/main/scss into
build/generated/sassfx/main. When the Java plugin is present, the generated
files are included in processResources automatically.
The target selector accepts:
| Selector | Output |
|---|---|
css |
Standard CSS |
css/javafx@8 through css/javafx@27 |
Validated JavaFX CSS |
bss/javafx@8 through bss/javafx@27 |
JavaFX BSS |
Add the core library from Maven Central:
dependencies {
implementation("org.glavo:sassfx-core:<version>")
}Compile a stylesheet to standard CSS:
import org.glavo.sassfx.CssTarget;
import org.glavo.sassfx.SassCompiler;
import org.glavo.sassfx.SassSource;
import java.nio.file.Files;
import java.nio.file.Path;
var result = new SassCompiler().compile(
SassSource.fromFile(Path.of("style.scss")),
CssTarget.DEFAULT
);
Files.writeString(Path.of("style.css"), result.output());Use JavaFXCssTarget for validated JavaFX CSS and BssTarget for binary
stylesheets. CompileOptions configures source maps, load paths, diagnostics,
custom importers, and custom Sass functions.
Run the self-contained CLI JAR:
java -jar sassfx-cli-<version>.jar style.scss -o style.cssSelect a JavaFX target when needed:
java -jar sassfx-cli-<version>.jar \
--target bss/javafx@27 \
style.scss \
-o style.bssUse --help for the complete option reference:
java -jar sassfx-cli-<version>.jar --helpThe sassfx-embedded artifact provides a standalone Embedded Sass Protocol
endpoint:
java -jar sassfx-embedded-<version>.jarThe CLI artifact exposes the same endpoint through --embedded. This
interface is intended for Sass host implementations; ordinary application
builds should normally use the Gradle plugin, CLI, or Java API.
Use the checked-in Gradle Wrapper:
./gradlew checkOn Windows:
.\gradlew.ps1 checkProduct code and artifacts target Java 17. Generating Javadoc requires a JDK
25 toolchain because the sources use Markdown-style /// documentation
comments.
- CHANGELOG.md records user-visible changes and current limitations.
- UPSTREAM.md records pinned Sass compatibility baselines.
- ORACLES.md describes JavaFX runtime verification.
- RELEASING.md describes the release workflow.
- THIRD-PARTY-NOTICES.md contains attribution and compatibility-source notices.
SassFX is licensed under the Mozilla Public License 2.0.