forked from tuhlmann/lein-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move to only supporting dart-sass
- Loading branch information
hackeryarn
committed
Oct 3, 2023
1 parent
3e2320b
commit e5579a5
Showing
8 changed files
with
130 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
(defproject lein-sass "0.6.0" | ||
(defproject lein-sass "1.0.0" | ||
:description "SASS autobuilder plugin" | ||
:url "https://github.com/hackeryarn/lein-sass" | ||
:license {:name "Eclipse Public License - v 1.0" | ||
:url "http://www.eclipse.org/legal/epl-v10.html" | ||
:distribution :repo} | ||
|
||
:dependencies [[org.clojure/clojure "1.6.0"] | ||
[com.cemerick/pomegranate "0.2.0"] | ||
[clojure-watch "LATEST"] | ||
[me.raynes/fs "1.4.6"]] | ||
:dependencies [[org.clojure/clojure "1.11.1"]] | ||
|
||
:profiles {:dev {:dependencies [[speclj "2.5.0"]] | ||
:plugins [[speclj "2.5.0"]] | ||
:profiles {:dev {:dependencies [[speclj "3.4.3"]] | ||
:plugins [[speclj "3.4.3"]] | ||
:test-paths ["spec/"]} | ||
|
||
:spec {:sass {:src "spec/files" | ||
:output-directory "spec/out"}} | ||
|
||
:spec-map {:sass {:src "spec/files" | ||
:source-maps true | ||
:output-directory "spec/out/map"}}} | ||
:spec {:sass {:targets ["spec/files:spec/out"]}} | ||
:spec-map {:sass {:targets ["spec/files:spec/out/map"] | ||
:source-maps true}}} | ||
|
||
:hooks [leiningen.sass] | ||
|
||
:eval-in-leiningen true | ||
:min-lein-version "2.0.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
(ns leiningen.cleaner | ||
(:use leiningen.utils) | ||
(:require [clojure.java.io :as io])) | ||
(:require [leiningen.utils :as utils] | ||
[clojure.java.io :as io] | ||
[clojure.string :as str])) | ||
|
||
(defn clean-all! | ||
[{:keys [output-directory delete-output-dir] :as options}] | ||
(doseq [[_ dest-file] (files-from options)] | ||
(delete-file! (io/file dest-file)) | ||
(delete-file! (io/file (str (.getPath dest-file) ".map")))) | ||
(defn target->dest-file [target] | ||
(-> target | ||
(str/split #":" 2) | ||
last | ||
io/file)) | ||
|
||
(when (and delete-output-dir (exists output-directory) (dir-empty? output-directory)) | ||
(println (str "Destination folder " output-directory " is empty - Deleting it")) | ||
(delete-directory-recursively! output-directory))) | ||
(defn clean-all! | ||
[{:keys [targets]}] | ||
(doseq [dest-file (map target->dest-file targets)] | ||
(utils/delete-file! dest-file) | ||
(utils/delete-file! (io/file (str (.getPath dest-file) ".map"))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,17 @@ | ||
(ns leiningen.render | ||
(:use leiningen.utils) | ||
(:require [clojure-watch.core :refer [start-watch]] | ||
[clojure.java.shell :as shell] | ||
[clojure.java.io :as io] | ||
[clojure.string :as string]) | ||
(:import java.lang.Thread)) | ||
(:require [leiningen.utils :as utils] | ||
[clojure.java.shell :as shell])) | ||
|
||
(defn- sassc-version* [] | ||
(->> (shell/sh "sassc" "-v") | ||
:out | ||
(re-find #"sassc: (.*)") | ||
second)) | ||
|
||
(defn- sassc-version [] | ||
(map #(Integer/parseInt %) (string/split (sassc-version*) #"\."))) | ||
|
||
(defn- source-map-args [] | ||
(let [[major minor patch] (sassc-version)] | ||
(if (and (>= major 3) (>= minor 4) (>= patch 6)) | ||
["--sourcemap=auto"] | ||
["--sourcemap"]))) | ||
|
||
(defn build-command-vec [src-file dest-file {:keys [command style source-maps]}] | ||
(let [src-path (.getPath src-file) | ||
dest-path (.getPath dest-file) | ||
sass-style (name style)] | ||
(case command | ||
:sassc (let [opts [ "-t" sass-style src-path dest-path] | ||
add-opts (if source-maps (source-map-args) [])] | ||
(concat ["sassc"] add-opts opts)) | ||
|
||
:sass (let [opts [ "--update" "--force" "-t" sass-style (str src-path ":" dest-path)] | ||
add-opts (if source-maps (source-map-args) [])] | ||
(concat ["sass"] add-opts opts)) | ||
|
||
:dart-sass (let [opts [ "--update" "-s" sass-style (str src-path ":" dest-path)] | ||
add-opts (if source-maps ["--source-map"] [])] | ||
(concat ["sass"] add-opts opts))))) | ||
(defn build-command-vec [{:keys [targets style source-maps watch]}] | ||
(let [sass-style (name style) | ||
opts (cond-> ["--update" "--style" sass-style] | ||
(not source-maps) (conj "--no-source-map") | ||
watch (conj "--watch"))] | ||
(concat ["sass"] opts targets))) | ||
|
||
(defn render | ||
[src-file dest-file options] | ||
(when (and (not (is-partial? src-file)) (name-matches? src-file options)) | ||
(io/make-parents dest-file) | ||
(let [opts-vec (build-command-vec src-file dest-file options)] | ||
(println (str " [sass] - " (.getName src-file))) | ||
(println (:err (apply shell/sh opts-vec)))))) | ||
|
||
(defn render-once! | ||
[options] | ||
(let [descriptors (files-from options)] | ||
(doseq [[src-file dest-file] descriptors] | ||
(render src-file dest-file options)))) | ||
|
||
(defn render-loop! | ||
([options] | ||
(render-once! options) | ||
(start-watch [{:path (:src options) | ||
:event-types [:create :modify :delete] | ||
:callback (fn [_ _] (render-once! options)) | ||
:options {:recursive true}}]) | ||
(let [t (Thread/currentThread)] | ||
(locking t | ||
(.wait t))))) | ||
(let [opts-vec (build-command-vec options)] | ||
(println (str " [sass] - " (utils/targets->str (:targets options)))) | ||
(println (:err (apply shell/sh opts-vec))))) |
Oops, something went wrong.