lein-sass4clj のインストール
些細なことではまって時間がかかってしまったのでまとめておく。基本的に lein help sass4clj
読めという文を見逃がしていたことによる。
インストール
project.clj
の :plugins
に以下を追加する。最新のバージョンについては https://github.com/Deraen/sass4clj
[deraen/lein-sass4clj "0.3.1"]
はまった点
まず For each .sass or .scss file not starting with _ in source-dirs creates equivalent .css file.
という文を defproject
直下の :source
を意味すると勘違いした。
sass4clj 用の設定は :sass
の後に続ける。またこの時以下のようなエラーが出た。
$ lein sass4clj once java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol ...
:source-paths
はベクタで定義をする必要があった。leiningen の設定ファイル共通の話で、キーの名前が複数系の場合はベクタになることに今更気が付いた。
;; 間違い :sass {:source-paths "src/sass" :target-path "resources/public/css" :output-style :nested}
;; 正しい :sass {:source-paths ["src/sass"] :target-path "resources/public/css" :output-style :nested}
最後に以下のようなエラーが出てしばらく悩んだ。
$ lein sass4clj once Compiling ClojureScript... Compiling {sass}... test.sass Error: Invalid CSS after "body {": expected "}", was "{" on line 1 of src/sass/test.sass >> body { { ------^ Subprocess failed
これは SCSS シンタックスを使う場合は拡張子を .scss
にする必要があった。これは sass の仕様をよくわかってなかった。