Exporting / deploying from figwheel-main project

OK. Part 3 of me figuring out how to develop a ClojureScript project with CLI tools. (Previously was always using Lein)

Thanks to everyone’s help in the last two threads I hit upon

clojure -Tclj-new create :template figwheel-main :name myname/myapp :args '["+deps","–reagent"]'

as my way of creating a figwheel / reagent JS project using CLI tools.

I can run this with

clojure -M:fig:build

which sets up figwheel reloading etc. and lets me get on with writing my app.

I’ve now made the app I wanted to write (it wasn’t a big one) and want to deploy it. There’s no server. So I just want the HTML page + a single JS file.

There’s no immediately google-able answer to “what’s the CLI command to build a final cljs project”.

The first result : Clojure - Deps and CLI Guide doesn’t mention it. So I started following the tutorial on figwheel-main | Figwheel Main provides tooling for developing ClojureScript applications, especially the “The Build” and “Packaging up a single compiled artifact for production” sections.

So I’ve added a “build file” (as described on that page, it just contains {:main myname.myapp})

And I can now run my app with

clj -M --main cljs.main --compile myname.myapp --repl

(Though it’s not live reloading)

But when I try to run

clojure -M -m figwheel.main --optimizations whitespace  --build-once myname.myapp 

or just

clojure -M -m figwheel.main --optimizations whitespace  --build-once myapp

I get

Exception in thread "main" java.io.FileNotFoundException: Could not locate figwheel/main__init.class, figwheel/main.clj or figwheel/main.cljc on classpath.

And obviously no single big js file.

So can anyone tell me where I’ve gone wrong here? It’s true there’s no main.clj or similar. But why is it suddenly asking for one? When for the figwheel development it doesn’t seem to need one?

The template docs cover this. These are all specific to the template you use so you should consult the docs for that template.

See GitHub - bhauman/figwheel-main-template: A template to generate a minimal figwheel-main based ClojureScript project

TL;DR: clojure -M:fig:min instead of clojure -M:fig:build

1 Like

Thank you. That is extremely helpful.

That page wasn’t even linked from the tutorial I was following. :confused:

1 Like