Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created March 14, 2012 18:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/2038633 to your computer and use it in GitHub Desktop.
Save swannodette/2038633 to your computer and use it in GitHub Desktop.
project.clj
(defproject cljs-demo "0.1.0-SNAPSHOT"
:description "ClojureScripting!"
:dev-dependencies [[lein-cljsbuild "0.1.2"]]
:cljsbuild {:builds [{:source-path "src"
:compiler {:optimizations :simple
:pretty-print true}}]})
;; then from project directory
;; ---------------------------
;;
;; lein deps - grabs dependencies
;; lein cljsbuild auto - to start watching files as they change
;; lein trampoline cljsbuild repl-listen - for browser REPL
@Gozala
Copy link

Gozala commented Mar 14, 2012

In fact that's more or less what I ended up with:

(defproject learn-cljs-intro "0.0.1"
  :plugins [[lein-cljsbuild "0.1.2"]]
  :cljsbuild
  { :builds
    [{ :source-path "src"
       :compiler
       { :output-to "lib/core.js"
         :optimizations :whitespace
         :pretty-print true }}]})

and then my core.cljs is something like this:

(ns learn-cljs
  (:require [clojure.browser.repl :as repl]))
(repl/connect "http://localhost:9000/repl")

Which works if I run server hosting my html page, but sometimes it get's stuck or has some random glitches, so I gave up on it for the time being. Ideally my project files would have being hosted on 'http://localhost:9000/' so I could just start palying with it, but I have to learn more before I'd be able to patch "lein-cljsbuild" to do that :)

Thanks for the hints! Now I wish I ranted yesterday about this, that would have saved me a lot of time :)

@swannodette
Copy link
Author

It's early days yet :) The Browser REPL should always work, though sometime you need to refresh the browser to make sure a connection has been made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment