Last active
August 29, 2015 14:14
-
-
Save jmreidy/6d42b5d1478d5bb4e293 to your computer and use it in GitHub Desktop.
CLJS setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns project-name.server | |
(:require [clojure.java.io :as io] | |
[project-name.dev :refer [is-dev? inject-devmode-html]] | |
[compojure.core :refer [GET defroutes]] | |
[compojure.route :refer [resources]] | |
[compojure.handler :refer [api]] | |
[net.cgrand.enlive-html :refer [deftemplate]] | |
[net.cgrand.reload :refer [auto-reload]] | |
[ring.middleware.reload :as reload] | |
[environ.core :refer [env]] | |
[org.httpkit.server :refer [run-server]])) | |
(deftemplate page | |
(io/resource "index.html") [] [:body] (if is-dev? inject-devmode-html identity)) | |
(defroutes routes | |
(resources "/") | |
(GET "/*" req (page))) | |
(def http-handler | |
(if is-dev? | |
(reload/wrap-reload (api #'routes)) | |
(api routes))) | |
(defn run [& [port]] | |
(defonce ^:private server | |
(do | |
(when is-dev? | |
(auto-reload *ns*) | |
) | |
(let [port (Integer. (or port (env :port) 10555))] | |
(print "Starting web server on port" port ".\n") | |
(run-server http-handler {:port port | |
:join? false})))) | |
server) | |
(defn -main [& [port]] | |
(run port)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns project-name.dev | |
(:require [project-name.core :as core] | |
[figwheel.client :as figwheel :include-macros true] | |
)) | |
(enable-console-print!) | |
(figwheel/start { | |
:websocket-url "ws://localhost:3449/figwheel-ws" | |
:jsload-callback (fn [] (core/main))}) | |
(core/main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject project-name "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:source-paths ["src/clj" "src/cljs"] | |
:dependencies [[org.clojure/clojure "1.7.0-alpha5"] | |
[org.clojure/clojurescript "0.0-2727" :scope "provided"] | |
[org.clojure/core.async "0.1.346.0-17112a-alpha"] | |
;server | |
[http-kit "2.1.19"] | |
[ring "1.3.2"] | |
[ring/ring-defaults "0.1.2"] | |
[compojure "1.3.1"] | |
[jmreidy/clj-orchestrate "0.1.0"] | |
[enlive "1.1.5"] | |
;client | |
[org.omcljs/om "0.8.8"] | |
[prismatic/om-tools "0.3.10"] | |
;env | |
[figwheel "0.2.3-SNAPSHOT"] | |
[figwheel-sidecar "0.2.3-SNAPSHOT"] | |
[environ "1.0.0"] | |
] | |
:plugins [[lein-cljsbuild "1.0.4"] | |
[lein-environ "1.0.0"]] | |
:min-lein-version "2.5.0" | |
:uberjar-name "project-name.jar" | |
:cljsbuild {:builds {:app {:source-paths ["src/cljs"] | |
:compiler {:output-to "resources/public/js/app.js" | |
:output-dir "resources/public/js/out" | |
:source-map "resources/public/js/out.js.map" | |
:optimizations :none | |
:pretty-print true}}}} | |
:profiles {:dev {:repl-options {:init-ns project-name.server} | |
:plugins [[lein-figwheel "0.2.3-SNAPSHOT"]] | |
:figwheel {:http-server-root "public" | |
:server-port 3449 | |
:css-dirs ["resources/public/css"]} | |
:env {:is-dev true} | |
:cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}} | |
:uberjar {:hooks [leiningen.cljsbuild] | |
:env {:production true} | |
:omit-source true | |
:aot :all | |
:cljsbuild {:builds {:app | |
{:source-paths ["env/prod/cljs"] | |
:compiler | |
{:optimizations :advanced | |
:pretty-print false}}}}}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome. Thanks!