Skip to content

Commit d0d8776

Browse files
committed
Add lessjs task
This task uses npm in order to install and launch the lessc compiler against the input .less file. The output will be included into the fileset by default. At the moment only the --include-dirs option is handled and passed to lessc.
1 parent 60331bf commit d0d8776

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

boot.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BOOT_VERSION=2.7.2

build.boot

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(set-env! :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"]
2+
[degree9/boot-npm "1.7.0-SNAPSHOT"]
3+
[adzerk/bootlaces "0.1.13" :scope "test"]
4+
[degree9/boot-semver "1.6.0" :scope "test"]]
5+
:resource-paths #{"src"})
6+
7+
(require '[degree9.boot-semver :refer :all])
8+
9+
(task-options!
10+
pom {:project 'degree9/boot-css
11+
:description "CSS Preprocessors for boot-clj."
12+
:url "https://github.com/degree9/boot-exec"
13+
:scm {:url "https://github.com/degree9/boot-exec"}})
14+
15+
(deftask develop
16+
"Build boot-css for development."
17+
[]
18+
(comp
19+
(version :develop true
20+
:minor 'inc
21+
:patch 'zero
22+
:pre-release 'snapshot)
23+
(watch)
24+
(target)
25+
(build-jar)))
26+
27+
(deftask deploy
28+
"Build boot-css and deploy to clojars."
29+
[]
30+
(comp
31+
(version)
32+
(target)
33+
(build-jar)
34+
(push-release)))

src/degree9/boot_css.clj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(ns degree9.boot-css
2+
(:require [boot.core :as boot]
3+
[clojure.string :as str]
4+
[clojure.java.io :as io]
5+
[boot.util :as u]
6+
[degree9.boot-npm :as npm]))
7+
8+
(boot/deftask lessc
9+
"Compile CSS using the npm version of Less."
10+
[l less-path PATH str "Path to the .less file to compile (relative to the fileset)."
11+
i include-dirs PATH #{str} "Include directories for lessc."]
12+
(let [tmp (boot/tmp-dir!)]
13+
(boot/with-pre-wrap [fs]
14+
(let [less-tmp (boot/tmp-get fs less-path)]
15+
(assert less-tmp (format "Less-path (%s) should point to a file in the classpath." less-path))
16+
(let [compiled-file (io/file tmp (str/replace less-path #"\.less$" ".css"))
17+
include-dirs (->> [(boot/tmp-dir less-tmp)]
18+
(into (or include-dirs #{}))
19+
(str/join ":"))
20+
mw (npm/exec :module "less"
21+
:process "lessc"
22+
:arguments [(str "--include-path=" include-dirs)
23+
(-> less-tmp boot/tmp-file .getAbsolutePath)
24+
(.getAbsolutePath compiled-file)])]
25+
(u/dbug* "Less boot dir: %s\n" (boot/tmp-dir less-tmp))
26+
(u/dbug* "Less boot file: %s\n" (-> less-tmp boot/tmp-file .getAbsolutePath))
27+
(u/dbug* "Less boot target: %s\n" (.getAbsolutePath compiled-file))
28+
29+
((mw identity) fs) ;; only for side effects on tmp folder
30+
(-> fs (boot/add-resource tmp) boot/commit!))))))

version.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Mon May 01 18:58:18 MDT 2017
2+
VERSION=1.0.0

0 commit comments

Comments
 (0)