Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(import ./html :as html) | ||
|
||
|
||
(defn- concat-files [filenames ext] | ||
(var parts @[]) | ||
(loop [filename :in filenames] | ||
(let [f (file/open (string "public/" filename) :r) | ||
str (file/read f :all) | ||
parts (array/push parts str)] | ||
(file/close f)) | ||
(let [f (file/open (string "public/bundle." ext) :w)] | ||
(file/write f (string/join parts "\n\n")) | ||
(file/close f)))) | ||
|
||
|
||
(def- css? (partial string/has-suffix? ".css")) | ||
(def- js? (partial string/has-suffix? ".js")) | ||
(def- bundle? (partial string/has-prefix? "bundle")) | ||
|
||
|
||
(defn bundle [[path]] | ||
(let [files (sort (os/dir (or path "public"))) | ||
files (filter |(not (bundle? $)) files) | ||
css-files (filter css? files) | ||
js-files (filter js? files)] | ||
(concat-files css-files "css") | ||
(concat-files js-files "js"))) |
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