adzerk-oss / boot-reload

Boot task providing live-reload of browser css, images, etc.
Eclipse Public License 1.0
87 stars 35 forks source link

boot-reload in vagrant ubuntu [bug] #91

Closed karneaud closed 8 years ago

karneaud commented 8 years ago

I seem to be having a bit of a task getting stuff to reload using boot

i have installed the saapas project on a vagrant running ubuntu 64

the following is the build.boot

(set-env!
  ; Test path can be included here as source-files are not included in JAR
  ; Just be careful to not AOT them
  :source-paths #{"src/cljs" "src/less" "src/scss" "test/clj" "test/cljs"}
  :resource-paths #{"src/clj" "src/cljc"}
  :dependencies '[[org.clojure/clojure    "1.9.0-alpha10"]
                  [org.clojure/clojurescript "1.9.89"]

                  [boot/core              "2.6.0"      :scope "test"]
                  [adzerk/boot-cljs       "1.7.228-1"  :scope "test"]
                  [adzerk/boot-cljs-repl  "0.3.3"      :scope "test"]
                  [crisptrutski/boot-cljs-test "0.2.2-SNAPSHOT" :scope "test"]
                  [com.cemerick/piggieback "0.2.1"     :scope "test"]
                  [weasel                 "0.7.0"      :scope "test"]
                  [org.clojure/tools.nrepl "0.2.12"    :scope "test"]
                  [adzerk/boot-reload     "0.4.11"     :scope "test"]
                  [metosin/boot-alt-test  "0.1.0"      :scope "test"]
                  [deraen/boot-less       "0.5.0"      :scope "test"]
                  ;; For boot-less
                  [org.slf4j/slf4j-nop    "1.7.21"     :scope "test"]
                  [deraen/boot-sass       "0.2.1"      :scope "test"]
                  [deraen/boot-ctn        "0.1.0"      :scope "test"]

                  ; Backend
                  [http-kit "2.2.0"]
                  [org.clojure/tools.namespace "0.2.11"]
                  [reloaded.repl "0.2.2"]
                  [com.stuartsierra/component "0.3.1"]
                  [metosin/ring-http-response "0.8.0"]
                  [ring "1.5.0"]
                  [compojure "1.5.1"]
                  [hiccup "1.0.5"]

                  ; Frontend
                  [reagent "0.6.0-rc"]
                  [binaryage/devtools "0.7.2"]

                  ; LESS
                  [org.webjars/bootstrap "3.3.6"]
                  ; SASS
                  [org.webjars.bower/bootstrap "4.0.0-alpha" :exclusions [org.webjars.bower/jquery]]])

(require
  '[adzerk.boot-cljs      :refer [cljs]]
  '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl repl-env]]
  '[adzerk.boot-reload    :refer [reload]]
  '[metosin.boot-alt-test  :refer [alt-test]]
  '[deraen.boot-less      :refer [less]]
  '[deraen.boot-sass      :refer [sass]]
  '[deraen.boot-ctn       :refer [init-ctn!]]
  '[crisptrutski.boot-cljs-test :refer [test-cljs prep-cljs-tests run-cljs-tests]]
  '[backend.boot          :refer [start-app]]
  '[reloaded.repl         :refer [go reset start stop system]])

; Watch boot temp dirs
(init-ctn!)

(task-options!
  pom {:project 'saapas
       :version "0.1.0-SNAPSHOT"
       :description "Application template for Cljs/Om with live reloading, using Boot."
       :license {"The MIT License (MIT)" "http://opensource.org/licenses/mit-license.php"}}
  aot {:namespace #{'backend.main}}
  jar {:main 'backend.main}
  cljs {:source-map true}
  less {:source-map true}
  repl {:host "0.0.0.0" :port 9000 :bind "0.0.0.0"}
  cljs-repl {:ip "0.0.0.0" :port 9000 :nrepl-opts {:host "0.0.0.0" :port 9000 }}
  reload {
          ;; :open-file "vim --servername 0.0.0.0 --remote-silent +norm%sG%s| %s"
          :ids #{"js/main"}
          :port 9001
          ; :ws-host "0.0.0.0"
          ; :ip "0.0.0.0"
          ; :asset-host "localhost:3000"
          ; :asset-path "target"
          ; :cljs-asset-path "src/cljs"
          }
  start-app {:port 3000 }
  )

(deftask dev
  "Start the dev env..."
  [s speak           bool "Notify when build is done"
   p port       PORT int  "Port for web server"
   a use-sass        bool "Use Scss instead of less"
   t test-cljs       bool "Compile and run cljs tests"]
  (comp
    (start-app)
    (watch)
    (if use-sass
      (sass)
      (less))
    (reload)
    ; This starts a repl server with piggieback middleware
    (cljs-repl :ids #{"js/main"})
    (cljs :ids #{"js/main"})
    (if speak (boot.task.built-in/speak) identity)))

(deftask run-tests
  [a autotest bool "If no exception should be thrown when tests fail"]
  (comp
    (alt-test :fail (not autotest))
    ;; FIXME: This is not a good place to define which namespaces to test
    (test-cljs :namespaces #{"frontend.core-test"})))

(deftask autotest []
  (comp
    (watch)
    (run-tests :autotest true)))

(deftask package
  "Build the package"
  []
  (comp
    (less :compression true)
    (cljs :optimizations :advanced)
    (aot)
    (pom)
    (uber)
    (jar)
    (target)))

when i run boot dev i get the following log output

Starting reload server on ws://localhost:9001 Writing adzerk/boot_reload/init2401.cljs to connect to ws://localhost:9001... Writing boot_cljs_repl.cljs... Starting web server on http://localhost:3000

Starting file watcher (CTRL-C to quit)...

Compiling {less}... 2 changed files. Adding :require adzerk.boot-reload.init2401 to main.cljs.edn... nREPL server started on port 9000 on host 0.0.0.0 - nrepl://0.0.0.0:9000 Adding :require adzerk.boot-cljs-repl to main.cljs.edn... Compiling ClojureScript... ? js/main.js Elapsed time: 45.321 sec

when i open up the browser I get

Reload websocket connected.

However if I were to edit a cljs or cli file in the source or resource path. nothing happens.

Does boot-reload work in vagrant ubuntu environments?

karneaud commented 8 years ago

my repo

Deraen commented 8 years ago

Example repo doesn't no longer exists so I'm going to close this.