From e1c40123cad15931b31ffa389724ddc8bc701b87 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:11:35 +0200 Subject: [PATCH 1/6] shadow-cljs.edn template now has two build IDs - :app -> resources/public/js (development/watch) - :app-prod -> target/classes/cljsbuild/public/js (release) --- .../resources/modules/kit/cljs/assets/shadow-cljs.edn | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/kit-generator/test/resources/modules/kit/cljs/assets/shadow-cljs.edn b/libs/kit-generator/test/resources/modules/kit/cljs/assets/shadow-cljs.edn index 483186b..0326520 100644 --- a/libs/kit-generator/test/resources/modules/kit/cljs/assets/shadow-cljs.edn +++ b/libs/kit-generator/test/resources/modules/kit/cljs/assets/shadow-cljs.edn @@ -5,7 +5,11 @@ [reagent "2.0.1"] [cljs-ajax "0.8.4"]] :builds {:app {:target :browser - :output-dir "target/classes/cljsbuild/public/js" + :output-dir "resources/public/js" :asset-path "/js" :modules {:app {:entries [<>.core]}} - :devtools {:after-load <>.core/mount-root}}}} + :devtools {:after-load <>.core/mount-root}} + :app-prod {:target :browser + :output-dir "target/classes/cljsbuild/public/js" + :asset-path "/js" + :modules {:app {:entries [<>.core]}}}}} From c32131e7d98beff36bacd0228508c3d0cc201152 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:11:44 +0200 Subject: [PATCH 2/6] Update build-cljs function to use app-prod Changed the build-cljs function to release the production version of the app instead of the development version. This ensures that the correct build is generated for production deployment. --- .../test/resources/modules/kit/cljs/assets/build.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj b/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj index 9570b17..9edf52a 100644 --- a/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj +++ b/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj @@ -29,8 +29,8 @@ :target-dir class-dir})) (defn build-cljs [_] - (println "npx shadow-cljs release app...") - (let [{:keys [exit] :as s} (sh "npx" "shadow-cljs" "release" "app")] + (println "npx shadow-cljs release app-prod...") + (let [{:keys [exit] :as s} (sh "npx" "shadow-cljs" "release" "app-prod")] (when-not (zero? exit) (throw (ex-info "could not compile cljs" s))))) From 286bf298c3af7e7b31b0d63176c1f3c8c429a3a8 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:11:53 +0200 Subject: [PATCH 3/6] Update build-cljs function to use app-prod Changed the build-cljs function to release the app-prod version instead of the default app. This ensures that the production build is correctly generated when the function is called. --- libs/kit-generator/test/resources/modules/kit/cljs/config.edn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/kit-generator/test/resources/modules/kit/cljs/config.edn b/libs/kit-generator/test/resources/modules/kit/cljs/config.edn index 6c6b39a..564f22f 100644 --- a/libs/kit-generator/test/resources/modules/kit/cljs/config.edn +++ b/libs/kit-generator/test/resources/modules/kit/cljs/config.edn @@ -28,9 +28,9 @@ :path "build.clj" :action :append-build-task :value (defn build-cljs [] - (println "npx shadow-cljs release app...") + (println "npx shadow-cljs release app-prod...") (let [{:keys [exit] - :as s} (sh "npx" "shadow-cljs" "release" "app")] + :as s} (sh "npx" "shadow-cljs" "release" "app-prod")] (when-not (zero? exit) (throw (ex-info "could not compile cljs" s)))))} {:type :clj From 0d04cf07a69879a5572fb33995a262f2a58832bf Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:12:00 +0200 Subject: [PATCH 4/6] Add resources/public/js/ to .gitignore This change prevents the resources/public/js/ directory from being tracked by Git, ensuring that generated files and build artifacts do not clutter the repository. --- libs/deps-template/resources/io/github/kit_clj/kit/gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/deps-template/resources/io/github/kit_clj/kit/gitignore b/libs/deps-template/resources/io/github/kit_clj/kit/gitignore index ec15fe6..573ce5c 100644 --- a/libs/deps-template/resources/io/github/kit_clj/kit/gitignore +++ b/libs/deps-template/resources/io/github/kit_clj/kit/gitignore @@ -18,3 +18,4 @@ modules/ .clj-kondo/.cache/ .calva/output-window/ .lsp/.cache/ +resources/public/js/ From 162f8de9cb8f5a67a67954cd4259d54fe7e8a634 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:23:09 +0200 Subject: [PATCH 5/6] Add copy-tree dependency and update build-cljs This change adds the `copy-tree` function from `babashka.fs` to the build process in `build.clj`. It also ensures that the output directory is cleaned before copying the compiled files, improving the build process for the application. --- .../test/resources/modules/kit/cljs/config.edn | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/kit-generator/test/resources/modules/kit/cljs/config.edn b/libs/kit-generator/test/resources/modules/kit/cljs/config.edn index 564f22f..ed18994 100644 --- a/libs/kit-generator/test/resources/modules/kit/cljs/config.edn +++ b/libs/kit-generator/test/resources/modules/kit/cljs/config.edn @@ -23,7 +23,8 @@ {:type :clj :path "build.clj" :action :append-requires - :value ["[clojure.java.shell :refer [sh]]"]} + :value ["[clojure.java.shell :refer [sh]]" + "[babashka.fs :refer [copy-tree]]"]} {:type :clj :path "build.clj" :action :append-build-task @@ -32,7 +33,9 @@ (let [{:keys [exit] :as s} (sh "npx" "shadow-cljs" "release" "app-prod")] (when-not (zero? exit) - (throw (ex-info "could not compile cljs" s)))))} + (throw (ex-info "could not compile cljs" s))) + (b/delete {:path "target/classes/public/js"}) + (copy-tree "target/classes/cljsbuild/public" "target/classes/public")))} {:type :clj :path "build.clj" :action :append-build-task-call From 3b148c3acd824fc757959637989167521530cc11 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 28 Apr 2026 18:23:15 +0200 Subject: [PATCH 6/6] Add copy-tree usage in build-cljs function This change integrates the copy-tree function to ensure that the compiled JavaScript files are correctly copied to the public directory after building with shadow-cljs. This helps maintain the proper directory structure for the output files. --- .../test/resources/modules/kit/cljs/assets/build.clj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj b/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj index 9edf52a..5471781 100644 --- a/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj +++ b/libs/kit-generator/test/resources/modules/kit/cljs/assets/build.clj @@ -2,6 +2,7 @@ (:require [clojure.tools.build.api :as b] [clojure.string :as string] [clojure.java.shell :refer [sh]] + [babashka.fs :refer [copy-tree]] [deps-deploy.deps-deploy :as deploy] [kit.generator.io :as io])) @@ -32,7 +33,9 @@ (println "npx shadow-cljs release app-prod...") (let [{:keys [exit] :as s} (sh "npx" "shadow-cljs" "release" "app-prod")] (when-not (zero? exit) - (throw (ex-info "could not compile cljs" s))))) + (throw (ex-info "could not compile cljs" s))) + (b/delete {:path "target/classes/public/js"}) + (copy-tree "target/classes/cljsbuild/public" "target/classes/public"))) (defn uber [_] (b/compile-clj {:basis basis