lein-less not running on figwheel start or when a .less file changes

415 views Asked by At

I'm trying to setup a clojurescript project that uses the lein-less plugin to compile .less files. I should say I'm new to clojurescript. The problem is that it doesn't seem to run. It doesn't run when I run "lein figwheel" and neither when I change a .less file.

This is my project.cljs

(defproject fed-repo "0.1.0"
    :description "Frontend Repository"
    :dependencies [
        [org.clojure/clojure "1.7.0"]
        [org.clojure/clojurescript "1.7.170"]
        [org.omcljs/om "1.0.0-alpha22"]
    ]
    :plugins [
        [lein-less "1.7.5"]
        [lein-cljsbuild "1.1.2"]
        [lein-figwheel "0.5.0-4"]
    ]
    :less {
        :source-paths ["src"]
        :target-path "resources/public/css"
    }
    :hooks [
        leiningen.less
        leiningen.cljsbuild
    ]
    :cljsbuild {
        :builds [
            {
                :id "dev"
                :source-paths ["src"]
                :figwheel true
                :compiler {
                    :main "fed-repo.core"
                    :asset-path "js/out"
                    :output-to "resources/public/js/main.js"
                    :output-dir "resources/public/js/out"
                }
            }
        ]
    }
)

What is wrong with this setup?

1

There are 1 answers

2
Chris Murphy On BEST ANSWER

Under :less the values for the keys :source-paths and :target-path need to go to actual files. You seem to have stopped at the directory.

Here's a working example:

:less {:source-paths ["src/less/"]
       :target-path "resources/public/css/"} 

Another issue is that you are not telling Figwheel where to hot code reload css from. Example:

:figwheel { :css-dirs ["resources/public/css"] }

With the set up so far there is still no .less -> .css file generation. You could have a terminal open that is dedicated to running lein less once. After changing the .less file run that command. Alternatively automatic generation can be done with the command lein less auto.