├── resources └── public │ ├── css │ └── style.css │ └── index.html ├── .gitignore ├── src └── my_web │ └── core.cljs ├── README.md ├── dev └── user.clj └── project.clj /resources/public/css/style.css: -------------------------------------------------------------------------------- 1 | /* some style */ 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /resources/public/js/compiled/** 2 | figwheel_server.log 3 | pom.xml 4 | *jar 5 | /lib/ 6 | /classes/ 7 | /out/ 8 | /target/ 9 | .lein-deps-sum 10 | .lein-repl-history 11 | .lein-plugins/ 12 | .repl 13 | .nrepl-port 14 | -------------------------------------------------------------------------------- /resources/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |

Figwheel template

13 |

Checkout your developer console.

14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/my_web/core.cljs: -------------------------------------------------------------------------------- 1 | (ns my-web.core 2 | (:require [reagent.core :as reagent :refer [atom]])) 3 | 4 | (enable-console-print!) 5 | 6 | (println "This text is printed from src/my-web/core.cljs. Go ahead and edit it and see reloading in action.") 7 | 8 | ;; define your app data so that it doesn't get over-written on reload 9 | 10 | (defonce app-state (atom {:text "Hello world!"})) 11 | 12 | 13 | (defn hello-world [] 14 | [:div {:class "container"} 15 | [:h1 {:class "jumbotron"} 16 | (:text @app-state)] 17 | [:p "I really love figwheel"] 18 | 19 | [:div {:class "row"} 20 | [:div {:class "col-md-3"} 21 | [:p "ACME Infrastructure Locations"] 22 | ] 23 | [:svg 24 | [:circle {:r 50, :cx 75, :cy 75, :fill "green"}]]]]) 25 | 26 | (reagent/render-component [hello-world] 27 | (. js/document (getElementById "app"))) 28 | 29 | (defn on-js-reload [] 30 | ;; optionally touch your app-state to force rerendering depending on 31 | ;; your application 32 | ;; (swap! app-state update-in [:__figwheel_counter] inc) 33 | ) 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # my-web 2 | 3 | FIXME: Write a one-line description of your library/project. 4 | 5 | ## Overview 6 | 7 | FIXME: Write a paragraph about the library/project and highlight its goals. 8 | 9 | ## Setup 10 | 11 | To get an interactive development environment run: 12 | 13 | lein figwheel 14 | 15 | and open your browser at [localhost:3449](http://localhost:3449/). 16 | This will auto compile and send all changes to the browser without the 17 | need to reload. After the compilation process is complete, you will 18 | get a Browser Connected REPL. An easy way to try it is: 19 | 20 | (js/alert "Am I connected?") 21 | 22 | and you should see an alert in the browser window. 23 | 24 | To clean all compiled files: 25 | 26 | lein clean 27 | 28 | To create a production build run: 29 | 30 | lein do clean, cljsbuild once min 31 | 32 | And open your browser in `resources/public/index.html`. You will not 33 | get live reloading, nor a REPL. 34 | 35 | ## License 36 | 37 | Copyright © 2014 FIXME 38 | 39 | Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version. 40 | -------------------------------------------------------------------------------- /dev/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:require 3 | [figwheel-sidecar.repl-api :as f])) 4 | 5 | ;; user is a namespace that the Clojure runtime looks for and 6 | ;; loads if its available 7 | 8 | ;; You can place helper functions in here. This is great for starting 9 | ;; and stopping your webserver and other development services 10 | 11 | ;; The definitions in here will be available if you run "lein repl" or launch a 12 | ;; Clojure repl some other way 13 | 14 | ;; You have to ensure that the libraries you :require are listed in your dependencies 15 | 16 | ;; Once you start down this path 17 | ;; you will probably want to look at 18 | ;; tools.namespace https://github.com/clojure/tools.namespace 19 | ;; and Component https://github.com/stuartsierra/component 20 | 21 | 22 | (defn fig-start 23 | "This starts the figwheel server and watch based auto-compiler." 24 | [] 25 | ;; this call will only work are long as your :cljsbuild and 26 | ;; :figwheel configurations are at the top level of your project.clj 27 | ;; and are not spread across different lein profiles 28 | 29 | ;; otherwise you can pass a configuration into start-figwheel! manually 30 | (f/start-figwheel!)) 31 | 32 | (defn fig-stop 33 | "Stop the figwheel server and watch based auto-compiler." 34 | [] 35 | (f/stop-figwheel!)) 36 | 37 | ;; if you are in an nREPL environment you will need to make sure you 38 | ;; have setup piggieback for this to work 39 | (defn cljs-repl 40 | "Launch a ClojureScript REPL that is connected to your build and host environment." 41 | [] 42 | (f/cljs-repl)) 43 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject my-web "0.1.0-SNAPSHOT" 2 | :description "FIXME: write this!" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | 7 | 8 | :min-lein-version "2.7.1" 9 | 10 | :dependencies [[org.clojure/clojure "1.9.0"] 11 | [org.clojure/clojurescript "1.10.238"] 12 | [org.clojure/core.async "0.4.474"] 13 | [reagent "0.7.0"]] 14 | 15 | :plugins [[lein-figwheel "0.5.16"] 16 | [lein-cljsbuild "1.1.7" :exclusions [[org.clojure/clojure]]]] 17 | 18 | :source-paths ["src"] 19 | 20 | :cljsbuild {:builds 21 | [{:id "dev" 22 | :source-paths ["src"] 23 | 24 | ;; The presence of a :figwheel configuration here 25 | ;; will cause figwheel to inject the figwheel client 26 | ;; into your build 27 | :figwheel {:on-jsload "my-web.core/on-js-reload" 28 | ;; :open-urls will pop open your application 29 | ;; in the default browser once Figwheel has 30 | ;; started and compiled your application. 31 | ;; Comment this out once it no longer serves you. 32 | :open-urls ["http://localhost:3449/index.html"]} 33 | 34 | :compiler {:main my-web.core 35 | :asset-path "js/compiled/out" 36 | :output-to "resources/public/js/compiled/my_web.js" 37 | :output-dir "resources/public/js/compiled/out" 38 | :source-map-timestamp true 39 | ;; To console.log CLJS data-structures make sure you enable devtools in Chrome 40 | ;; https://github.com/binaryage/cljs-devtools 41 | :preloads [devtools.preload]}} 42 | ;; This next build is a compressed minified build for 43 | ;; production. You can build this with: 44 | ;; lein cljsbuild once min 45 | {:id "min" 46 | :source-paths ["src"] 47 | :compiler {:output-to "resources/public/js/compiled/my_web.js" 48 | :main my-web.core 49 | :optimizations :advanced 50 | :pretty-print false}}]} 51 | 52 | :figwheel {;; :http-server-root "public" ;; default and assumes "resources" 53 | ;; :server-port 3449 ;; default 54 | ;; :server-ip "127.0.0.1" 55 | 56 | :css-dirs ["resources/public/css"] ;; watch and update CSS 57 | 58 | ;; Start an nREPL server into the running figwheel process 59 | ;; :nrepl-port 7888 60 | 61 | ;; Server Ring Handler (optional) 62 | ;; if you want to embed a ring handler into the figwheel http-kit 63 | ;; server, this is for simple ring servers, if this 64 | 65 | ;; doesn't work for you just run your own server :) (see lein-ring) 66 | 67 | ;; :ring-handler hello_world.server/handler 68 | 69 | ;; To be able to open files in your editor from the heads up display 70 | ;; you will need to put a script on your path. 71 | ;; that script will have to take a file path and a line number 72 | ;; ie. in ~/bin/myfile-opener 73 | ;; #! /bin/sh 74 | ;; emacsclient -n +$2 $1 75 | ;; 76 | ;; :open-file-command "myfile-opener" 77 | 78 | ;; if you are using emacsclient you can just use 79 | ;; :open-file-command "emacsclient" 80 | 81 | ;; if you want to disable the REPL 82 | ;; :repl false 83 | 84 | ;; to configure a different figwheel logfile path 85 | ;; :server-logfile "tmp/logs/figwheel-logfile.log" 86 | 87 | ;; to pipe all the output to the repl 88 | ;; :server-logfile false 89 | } 90 | 91 | 92 | ;; Setting up nREPL for Figwheel and ClojureScript dev 93 | ;; Please see: 94 | ;; https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl 95 | :profiles {:dev {:dependencies [[binaryage/devtools "0.9.9"] 96 | [figwheel-sidecar "0.5.16"] 97 | [cider/piggieback "0.3.1"]] 98 | ;; need to add dev source path here to get user.clj loaded 99 | :source-paths ["src" "dev"] 100 | ;; for CIDER 101 | ;; :plugins [[cider/cider-nrepl "0.12.0"]] 102 | :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]} 103 | ;; need to add the compliled assets to the :clean-targets 104 | :clean-targets ^{:protect false} ["resources/public/js/compiled" 105 | :target-path]}}) 106 | --------------------------------------------------------------------------------