diff --git a/src/figwheel/main.cljc b/src/figwheel/main.cljc index 087831c..2704911 100644 --- a/src/figwheel/main.cljc +++ b/src/figwheel/main.cljc @@ -844,7 +844,7 @@ classpath. Classpath-relative paths have prefix of @ or @/") (apply io/file) (.getPath))) - (defn auto-bundle [{:keys [options ::config] :as cfg}] + (defn config-auto-bundle [{:keys [options ::config] :as cfg}] ;; we only support webpack right now (if (:auto-bundle config) (cond-> cfg @@ -986,6 +986,18 @@ classpath. Classpath-relative paths have prefix of @ or @/") "figwheel-main.edn is valid \\(ツ)/")) (process-main-config main-edn))) + (defn config-use-ssl [{:keys [::config] :as cfg}] + (if (:use-ssl config) + (let [ssl-port (get-in config [:ring-server-options :ssl-port] figwheel.repl/default-ssl-port)] + (-> cfg + (assoc-in [::config :ring-server-options :ssl-port] ssl-port) + (update-in [::config :ring-server-options :ssl?] (fnil identity true)) + (update-in [::config :connect-url] + (fnil identity (format "wss://[[config-hostname]]:%d/figwheel-connect" ssl-port))) + (update-in [::config :open-url] + (fnil identity (format "https://[[server-hostname]]:%d" ssl-port))))) + cfg)) + ;; use tools reader read-string for better error messages #_(redn/read-string) (defn fetch-figwheel-main-edn [cfg] @@ -1300,7 +1312,7 @@ I.E. {:closure-defines {cljs.core/*global* \"window\" ...}}")) (:auto-testing (meta build-edn)) (update :extra-main-files assoc :auto-testing true)) } (merge {::build {:id build-id}}) - auto-bundle + config-auto-bundle config-default-dirs config-default-final-output-to config-clean-outputs!))) @@ -1716,7 +1728,8 @@ I.E. {:closure-defines {cljs.core/*global* \"window\" ...}}")) config-update-watch-dirs config-ensure-watch-dirs-on-classpath config-figwheel-mode? - auto-bundle + config-auto-bundle + config-use-ssl config-default-dirs config-default-final-output-to validate-output-paths-relationship! diff --git a/src/figwheel/main/schema/config.clj b/src/figwheel/main/schema/config.clj index a730774..4bff09b 100644 --- a/src/figwheel/main/schema/config.clj +++ b/src/figwheel/main/schema/config.clj @@ -751,6 +751,30 @@ Default value is nil :clean-outputs true" :group :common) +(s/def ::use-ssl boolean?) + +(def-spec-meta ::use-ssl + :doc "Takes a boolean value that if true indicates that +figwheel.main should configure its server to use https. + +This mainly adds default `:ring-server-options` for + + :ssl? true + :ssl-port 9533 + +This also changes the default `:connect-url` to +`wss://[[config-hostname]]:/figwheel-connect` and the +default `:open-url` to `https://[[server-hostname]]:` where +`` is replaced with the `:ssl-port` from +`:ring-server-options`. + +To complete your SSL configuration you will need to provide a +certificate and keys to options to `:ring-server-options` via a Java +KeyStore. + + :keystore + :password " + :group :common) ;; ------ Uncommon options ---------------------------------- @@ -939,6 +963,7 @@ be useful for certain docker environments. ::final-output-to ::auto-bundle ::clean-outputs + ::use-ssl ::cljsjs-resources