Fork me on GitHub

Config setting

Delete cljs option comment in _config.clj, and add cljs compiler.

{
 ;; clojurescript compile options
 ;; src-dir base is `:template-dir`
 ;; output-dir base is `:public-dir`
 :cljs {:src-dir       "cljs"
        :output-to     "js/main.js"
        :optimizations :whitespace
        :pretty-print  true}

 ;; add cljs compiler
 :compiler ["default" "cljs"]
 }

Following is default cljs options, so you can specify only difference.

{
 :src-dir       "cljs"
 :output-to     "js/main.js"
 :optimizations :whitespace
 :pretty-print  true
 }

Edit clojurescript source.

Open "template-dir/cljs/hello.cljs". Clojurescript source filepath is defined by :cljs {:src-dir} in _config.clj

(ns hello)

(defn ^:export myalert [msg]
  (.alert js/window (str "Hello, " msg)))

Edit html file.

<button onclick="hello.myalert('clojurescript world!!');">
Call clojurescript function!
</button>

Demo button.

Failed to compile?

if you failed to compile clojurescript, try followings

java.lang.AssertionError

cd MISAKI_HOME
rm -rf classes/cljs

Another errors

cd CLJS_OUTPUT_DIR
rm hello.js
rm -rf cljs

« Highlight Setting  |  Top Page  |  Switch Compiler »