Skip to content

ClojureScript Template Output Fix#178

Merged
yogthos merged 6 commits into
kit-clj:masterfrom
jramosg:js-output-dir
Apr 28, 2026
Merged

ClojureScript Template Output Fix#178
yogthos merged 6 commits into
kit-clj:masterfrom
jramosg:js-output-dir

Conversation

@jramosg
Copy link
Copy Markdown
Contributor

@jramosg jramosg commented Apr 28, 2026

This change updates the Kit ClojureScript module template so development and production builds use different Shadow build IDs and output directories.

Generated projects include this in resources/html/home.html:

<div id="app"></div>
<script src="/js/app.js"></script>

In development, /js/app.js must be available from project static resources, so the :app build should output to resources/public/js.

For production packaging, writing release artifacts into resources/public/js is not ideal because it mutates source resources. A dedicated production build target should write into a build output directory.

What changed

  1. shadow-cljs.edn template now has two build IDs:

    • :app -> resources/public/js (development/watch)
    • :app-prod -> target/classes/cljsbuild/public/js (release)
  2. build.clj template release command now uses:

(sh "npx" "shadow-cljs" "release" "app-prod")

It also removes stale copied JS output before the copy step:

(b/delete {:path "target/classes/public/js"})

This avoids FileAlreadyExistsException on repeated uberjar runs (for example
when target/classes/public/js/manifest.edn already exists from a previous run).

  1. The cljs module injection config was updated to append the same app-prod release command into generated build.clj.

  2. The base generated .gitignore template now includes:

resources/public/js/

This keeps transient dev output out of git when running npx shadow-cljs watch app.

jramosg added 6 commits April 28, 2026 18:11
- :app -> resources/public/js (development/watch)
- :app-prod -> target/classes/cljsbuild/public/js (release)
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.
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.
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.
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.
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.
@yogthos yogthos merged commit 0bd5245 into kit-clj:master Apr 28, 2026
1 check passed
@yogthos
Copy link
Copy Markdown
Collaborator

yogthos commented Apr 28, 2026

Thanks, that makes sense. Just pushed up a new template with the fix.

@jramosg jramosg deleted the js-output-dir branch April 28, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants