From d0d8776acebc0247d4736b8750c02039544a2250 Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Mon, 20 Nov 2017 16:19:59 -0800 Subject: [PATCH] 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. --- boot.properties | 1 + build.boot | 34 ++++++++++++++++++++++++++++++++++ src/degree9/boot_css.clj | 30 ++++++++++++++++++++++++++++++ version.properties | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 boot.properties create mode 100644 build.boot create mode 100644 src/degree9/boot_css.clj create mode 100644 version.properties diff --git a/boot.properties b/boot.properties new file mode 100644 index 0000000..eae6d09 --- /dev/null +++ b/boot.properties @@ -0,0 +1 @@ +BOOT_VERSION=2.7.2 diff --git a/build.boot b/build.boot new file mode 100644 index 0000000..7689906 --- /dev/null +++ b/build.boot @@ -0,0 +1,34 @@ +(set-env! :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"] + [degree9/boot-npm "1.7.0-SNAPSHOT"] + [adzerk/bootlaces "0.1.13" :scope "test"] + [degree9/boot-semver "1.6.0" :scope "test"]] + :resource-paths #{"src"}) + +(require '[degree9.boot-semver :refer :all]) + +(task-options! + pom {:project 'degree9/boot-css + :description "CSS Preprocessors for boot-clj." + :url "https://github.com/degree9/boot-exec" + :scm {:url "https://github.com/degree9/boot-exec"}}) + +(deftask develop + "Build boot-css for development." + [] + (comp + (version :develop true + :minor 'inc + :patch 'zero + :pre-release 'snapshot) + (watch) + (target) + (build-jar))) + +(deftask deploy + "Build boot-css and deploy to clojars." + [] + (comp + (version) + (target) + (build-jar) + (push-release))) diff --git a/src/degree9/boot_css.clj b/src/degree9/boot_css.clj new file mode 100644 index 0000000..056fea2 --- /dev/null +++ b/src/degree9/boot_css.clj @@ -0,0 +1,30 @@ +(ns degree9.boot-css + (:require [boot.core :as boot] + [clojure.string :as str] + [clojure.java.io :as io] + [boot.util :as u] + [degree9.boot-npm :as npm])) + +(boot/deftask lessc + "Compile CSS using the npm version of Less." + [l less-path PATH str "Path to the .less file to compile (relative to the fileset)." + i include-dirs PATH #{str} "Include directories for lessc."] + (let [tmp (boot/tmp-dir!)] + (boot/with-pre-wrap [fs] + (let [less-tmp (boot/tmp-get fs less-path)] + (assert less-tmp (format "Less-path (%s) should point to a file in the classpath." less-path)) + (let [compiled-file (io/file tmp (str/replace less-path #"\.less$" ".css")) + include-dirs (->> [(boot/tmp-dir less-tmp)] + (into (or include-dirs #{})) + (str/join ":")) + mw (npm/exec :module "less" + :process "lessc" + :arguments [(str "--include-path=" include-dirs) + (-> less-tmp boot/tmp-file .getAbsolutePath) + (.getAbsolutePath compiled-file)])] + (u/dbug* "Less boot dir: %s\n" (boot/tmp-dir less-tmp)) + (u/dbug* "Less boot file: %s\n" (-> less-tmp boot/tmp-file .getAbsolutePath)) + (u/dbug* "Less boot target: %s\n" (.getAbsolutePath compiled-file)) + + ((mw identity) fs) ;; only for side effects on tmp folder + (-> fs (boot/add-resource tmp) boot/commit!)))))) diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..1ac5651 --- /dev/null +++ b/version.properties @@ -0,0 +1,2 @@ +#Mon May 01 18:58:18 MDT 2017 +VERSION=1.0.0