Hey guys, This is an interesting thread, as I was playing around with Clojurescript. But I also had a hard time setting up a browser-connected repl. I wanted to do this from a raw leiningen2 project. I finally got it working and thought I would put this up as a reference to anyone wanting to do the same thing. I started from a raw lein2 project.clj file, added noir and clojurescript as dependencies, and got a browser-connected repl. This is the process I used.
# create project and setup directory structure lein.2 new foojs cd foojs mkdir -p public/{javascript,templ/cljs} # I manually add noir and clojurescript as dependencies. curl http://pastebin.com/raw.php?i=cmRA7jjj > project.clj # this core.clj i) uses noir and ii) uses a custom middleware to wrap and send files in the public/ directory curl http://pastebin.com/raw.php?i=b6mcjY2C > src/foojs/core.clj # the result foo.js gets loaded into the index.html, and connects the client to the cljs repl . replace <host-url> with yours curl http://pastebin.com/raw.php?i=Mg6vd5Mq > public/templ/cljs/foo.cljs # pulls in i) google closure and ii) foo.js, which connects the client to the cljs repl curl http://pastebin.com/raw.php?i=t73k12DM > public/index.html # I also use lein-cljsbuild to auto compile .cljs files. There are other options like i) lein-clojurescript and ii) noir-cljs, which I haven't tried yet lein cljsbuild once # Now i) start the repl, ii) start jetty in noir, and iii) fire up the cljs repl, waiting for a browser connection lein.2 repl => (require 'foojs.core) => (foojs.core/-main) Starting server... => (require '[cljs.repl :as repl]) => (require '[cljs.repl.browser :as browser]) => (def env (browser/repl-env :port 9000)) => (repl/repl env) "Type: " :cljs/quit " to quit" ClojureScript:cljs.user> #_=> ;; use your browser here, to open http:// <host-url>:8080 ClojureScript:cljs.user> #_=> (js/alert "I am an evil side-effect") HTH Tim Washington Interruptsoftware.ca 416.843.9060 On Tue, May 22, 2012 at 10:53 AM, D.Bushenko <d.bushe...@gmail.com> wrote: > David, > > I have just tried hosting index.html, main.js and out/ under > tomcat7/webapps/my/ directory, executed the cljs repl, navigated to > localhost:8080/my/index.html, and it worked! > > Thanks, that was very helpful! > Dmitry > > P.S. I think, the note about hosting index.html on some kind of webserver > should be added to the README.md. > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en