Skip to content

Instantly share code, notes, and snippets.

@fgui
Last active August 12, 2016 06:50
Show Gist options
  • Save fgui/f328b083de0da208448ae43fa35ec933 to your computer and use it in GitHub Desktop.
Save fgui/f328b083de0da208448ae43fa35ec933 to your computer and use it in GitHub Desktop.
how to cljs re-frame reagent browser android ios development
1) create project with re-natal
re-natal init MyApp reagent6
2) reorganize source code
cd my-app
mkdir alt
mv src/cljsjs alt
mv src/reagent alt
3) replace project.clj with other file in this gist
(keep the original project.clj for mobile production build)
(minified/optimized version of browser not in project.clj but easy to add)
4) start a figwheel for browser web
lein figwheel
5) start figwheel for mobile
lein with-profile mob figwheel android
or
lein with-profile mob figwheel ios
or
lein with-profile mob figwheel android ios
(defproject test-app "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"}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.89"]
[reagent "0.6.0-rc"]
[re-frame "0.7.0"]
[prismatic/schema "1.0.4"]
[figwheel-sidecar "0.5.4-7"]
[com.cemerick/piggieback "0.2.1"]]
:plugins [[lein-cljsbuild "1.1.3"]
[lein-figwheel "0.5.4-7"]]
:clean-targets ^{:protect false} ["target/"
"index.ios.js"
"index.android.js"
"resources/public/js/compiled"]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]]}
:figwheel {:server-port 3448}
:source-paths ["src"]
:cljsbuild {:builds {:browser {:source-paths ["src/"]
:figwheel {:on-jsload "test-app.web.core/mount-root"}
:compiler {:main test-app.web.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true}}}}
:repl-options {"nrepl-middleware" [cemerick.piggieback/wrap-cljs-repl]}
:profiles {:mob {:figwheel {:server-port 3449}
:cljsbuild {:builds {:ios {:source-paths ["src" "alt" "env/dev"]
:figwheel true
:compiler {:output-to "target/ios/not-used.js"
:main "env.ios.main"
:output-dir "target/ios"
:optimizations :none}}
:android {:source-paths ["src" "alt" "env/dev"]
:figwheel true
:compiler {:output-to "target/android/not-used.js"
:main "env.android.main"
:output-dir "target/android"
:optimizations :none}}}}
}
:prod {:cljsbuild {:builds {:ios {:source-paths ["src" "alt" "env/prod"]
:compiler {:output-to "index.ios.js"
:main "env.ios.main"
:output-dir "target/ios"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}}}
:android {:source-paths ["src" "alt" "env/prod"]
:compiler {:output-to "index.android.js"
:main "env.android.main"
:output-dir "target/android"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}}}}}}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment