Skip to content

Commit

Permalink
Fix dev/prod build settings.
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
chr15m committed May 13, 2018
1 parent ac6abfa commit 64125df
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 58 deletions.
2 changes: 1 addition & 1 deletion env/prod/cljs/omgnata/prod.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
;;ignore println statements in prod
(set! *print-fn* (fn [& _]))

(core/init!)
(core/init! true)
45 changes: 9 additions & 36 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@
[:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]

:source-paths ["src/clj" "src/cljc"]
:source-paths ["src/clj"]
:resource-paths ["resources" "target/cljsbuild"]

:minify-assets
{:assets
{"resources/public/css/site.min.css" "resources/public/css/site.css"}}
:minify-assets {:assets {"build/css/site.min.css" "resources/public/css/site.css"}}

:cljsbuild {:builds {:app {:source-paths ["src/cljs" "src/cljc"]
:cljsbuild {:builds {:app {:source-paths ["env/dev/cljs" "src/cljs"]
:compiler {:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:asset-path "js/out"
:main "omgnata.dev"
:optimizations :none
:pretty-print true}}
:min {:source-paths ["env/prod/cljs" "src/cljs" "src/cljc"]
:min {:source-paths ["env/prod/cljs" "src/cljs"]
:compiler {:output-to "build/js/app.js"
:main "omgnata.prod"
:optimizations :advanced
Expand All @@ -76,8 +75,7 @@
org.clojure/tools.analyzer.jvm]]
[org.clojure/tools.nrepl "0.2.12"]
[com.cemerick/piggieback "0.2.1"]
[pjstadig/humane-test-output "0.7.1"]
]
[pjstadig/humane-test-output "0.7.1"]]

:source-paths ["env/dev/clj"]
:plugins [[lein-figwheel "0.5.0-6"
Expand All @@ -89,40 +87,15 @@
org.clojure/tools.reader
org.clojure/clojurescript
org.clojure/core.async
org.clojure/tools.analyzer.jvm]]
]
org.clojure/tools.analyzer.jvm]]]

:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]

:figwheel {:http-server-root "public"
:server-port 3449
:nrepl-port 7002
:nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"
]
:nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"]
:css-dirs ["resources/public/css"]
:ring-handler omgnata.handler/app}
:ring-handler omgnata.handler/app}}})

:env {:dev "true"}

:cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]
:compiler {:main "omgnata.dev"
:source-map true}}



}
}}

:uberjar {:hooks [minify-assets.plugin/hooks]
:source-paths ["env/prod/clj"]
:prep-tasks ["compile" ["cljsbuild" "once"]]
:env {:production "true"}
:aot :all
:omit-source true
:cljsbuild {:jar true
:builds {:app
{:source-paths ["env/prod/cljs"]
:compiler
{:optimizations :advanced
:pretty-print false}}}}}})
6 changes: 0 additions & 6 deletions src/clj/omgnata/env.clj

This file was deleted.

6 changes: 0 additions & 6 deletions src/cljc/omgnata/util.cljc

This file was deleted.

21 changes: 12 additions & 9 deletions src/cljs/omgnata/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
[goog.events :as events]
[goog.history.EventType :as EventType])
(:require-macros
[omgnata.env :refer [get-env]]
[cljs.core.async.macros :refer [go]])
(:import goog.History))

(enable-console-print!)

; NOTE: these don't actually work in prod mode yet
(def server-url (if (get-env :dev) (str (.replace (-> js/document .-location .-href) ":3449" ":8000") "server.php") "server.php"))
(def poller-time (if (get-env :dev) 5 30))
(def server (atom {:url (str (.replace (-> js/document .-location .-href) ":3449" ":8000") "server.php")
:poller-time 5}))

(secretary/set-config! :prefix "#")

Expand Down Expand Up @@ -141,18 +139,18 @@
Server blocks if none since timestamp.
Returns a dictionary of :filename to text mappings."
(let [c (chan)]
(ajax-request {:uri server-url
(ajax-request {:uri (@server :url)
:method :get
:params {:timestamp timestamp
:live_for poller-time}
:live_for (@server :poller-time)}
:with-credentials true
:response-format (json-response-format)
:handler #(put! c %)})
c))

(defn update-file [fname text]
"Ask the server to update a particular text file with text contents."
(ajax-request {:uri server-url
(ajax-request {:uri (@server :url)
:method :post
:format (url-request-format)
:params {:filename (str fname ".txt")
Expand All @@ -168,7 +166,7 @@
(defn delete-file [fname]
"Ask the server to delete a single file."
; not RESTful because PHP doesn't support DELETE parameters well
(ajax-request {:uri server-url
(ajax-request {:uri (@server :url)
:method :get
:params {:delete (str fname ".txt")}
:with-credentials true
Expand Down Expand Up @@ -432,6 +430,11 @@
(defn mount-root []
(reagent/render [current-page] (.getElementById js/document "app")))

(defn init! []
(defn init! [& [prod]]
(if prod
(swap! server assoc
:url "server.php"
:poller-time 30)
(js/console.log "dev mode"))
(hook-browser-navigation!)
(mount-root))

0 comments on commit 64125df

Please sign in to comment.