Skip to content

Commit

Permalink
Expose create-css-asset for use in transpilers
Browse files Browse the repository at this point in the history
  • Loading branch information
magnars committed Dec 30, 2013
1 parent e25b54a commit 8191a7c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/optimus/assets/load_css.clj
Expand Up @@ -37,18 +37,20 @@
match match
(css-url-str (replacement-fn file url))))))) (css-url-str (replacement-fn file url)))))))


(defn paths-in-css [file] (defn- paths-in-css [file]
(->> file :contents (->> file :contents
(re-seq css-url-re) (re-seq css-url-re)
(map second) (map second)
(remove data-url?) (remove data-url?)
(remove external-url?) (remove external-url?)
(map #(combine-paths (original-path file) %)))) (map #(combine-paths (original-path file) %))))


(defn load-css-asset [public-dir path] (defn create-css-asset [path contents last-modified]
(let [resource (existing-resource public-dir path) (let [asset (-> (create-asset path contents
contents (slurp resource) :last-modified last-modified)
asset (-> (create-asset path contents
:last-modified (last-modified resource))
(replace-css-urls #(combine-paths (original-path %1) %2)))] (replace-css-urls #(combine-paths (original-path %1) %2)))]
(assoc asset :references (set (paths-in-css asset))))) (assoc asset :references (set (paths-in-css asset)))))

(defn load-css-asset [public-dir path]
(let [resource (existing-resource public-dir path)]
(create-css-asset path (slurp resource) (last-modified resource))))

0 comments on commit 8191a7c

Please sign in to comment.