Clojure wrapper for jsass JNA wrapper for Libsass. This repository also contains Boot and Leiningen tasks.
For parallel Less library check less4clj
Both sass4clj still works and will receive bug fixes, but the difference between libsass and dart-sass will continue growing.
Some ideas if you need to read files from the classpath or jar files:
clj
and unzip
)[org.webjars.bower/bootstrap "4.0.0-alpha"]
to use Bootstrap_
are partial files and should not be compiled into CSS files.sass
task (deraen.boot-sass/sass
)inputs
option.sass
or .scss
file not starting with _
in the fileset creates equivalent .css
file.boot sass --help
for task options.sass4clj
taskinputs
option.sass
or .scss
file not starting with _
in source-dirs creates equivalent .css
file.lein help sass4clj
for options.Test in the repository:
clj -m sass4clj.main --source-paths test-resources
Check clj -m sass4clj.main --help
for options.
Loading order for @import "{name}";
on file at {path}
{path}/{name}.sass
or {path}/{name}.scss
{source-path}/{name}.ext
(io/resource "{name}.ext")
(io/resource "{path}/{name}.ext")
META-INF/resources/webjars/{package}/{version}/{path}
can be referred using {package}/{path}
@import "bootstrap/scss/bootstrap.scss";
will import META-INF/resources/webjars/bootstrap/4.0.0-alpha/scss/bootstrap.scss
If you want to combine CLJS compilation with Shadow CLJS and Sass compilation, you can create your function which starts both watches and run this using shadow-cljs clj-run task.
(ns app.shadow
(:require [shadow.cljs.devtools.api :as shadow]
[sass4clj.api :as sass]
[clojure.edn :as edn]))
(defn watch
{:shadow/requires-server true}
[& _args]
;; Sass compilation probably starts faster.
;; Both watches keep running until ctrl-c.
(sass/start (-> (edn/read-string (slurp "sass4clj.edn"))
(assoc :target-path "target/dev/public/css")))
(shadow/watch :app))
The configuration file, sass4clj.edn, is also supported by sass4clj.main namespace. You could use that to compile CSS for your production build instead of the leiningen plugin.
And start the watch with (or with whatever tool you are using):
lein run -m shadow.cljs.devtools.cli clj-run app.shadow/watch
You need to ensure that the classpath used by shadow-cljs contains deraen/sass4clj
and any packages where you are importing sass files from.
If you don't have any slf4j implementations, you will see a warning:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
To disable this, add a no operation logger to your project. As this is only required
on the build phase, you can use :scope "test"
so that the dependency is not
transitive and is not included in Uberjar. Alternatively, you can add this
dependency to your Leiningen dev profile.
[org.slf4j/slf4j-nop "1.7.13" :scope "test"]
Copyright © 2014-2021 Juho Teperi
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation? These fine people already did:
Juho Teperi & Kimmo KoskinenEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close