From 7bd30a6204bd05aa7a43ef83e9c7331e9ee6c0ff Mon Sep 17 00:00:00 2001 From: Andelf Date: Sat, 18 Dec 2021 20:36:17 +0800 Subject: [PATCH] refactor(dev): use global dev-http in shadow-cljs --- .projectile | 1 - deps.edn | 2 +- public/index.html | 3 +-- resources/electron.html | 3 +-- resources/index.html | 3 +-- shadow-cljs.edn | 51 +++++++++++++++++++---------------------- 6 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.projectile b/.projectile index f3471f58b0..d55ff06403 100644 --- a/.projectile +++ b/.projectile @@ -5,7 +5,6 @@ -/.cpcache -/.shadow-cljs/ -/resources/static/js/cljs-runtime/ --/resources/static/js/common.js -/resources/static/js/main.js -/resources/static/js/sentry.min.js -/resources/static/js/highlight.min.js diff --git a/deps.edn b/deps.edn index 6d8002d4c1..2ced7467ad 100755 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ -{:paths ["src/main" "src/workspaces" "templates"] +{:paths ["src/main" "src/electron" "src/workspaces" "templates"] :deps {org.clojure/clojure {:mvn/version "1.10.0"} cheshire/cheshire {:mvn/version "5.10.0"} diff --git a/public/index.html b/public/index.html index 788278c06d..f52f9a4349 100644 --- a/public/index.html +++ b/public/index.html @@ -51,11 +51,10 @@ const portal = new MagicPortal(worker); - + - - + - diff --git a/resources/index.html b/resources/index.html index 35970892df..e8baffc066 100644 --- a/resources/index.html +++ b/resources/index.html @@ -54,10 +54,9 @@ const portal = new MagicPortal(worker); - + - diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 19cff8acd2..05e05805d3 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -2,27 +2,28 @@ {:deps true :nrepl {:port 8701} + ;; "." for /static + :dev-http {3001 ["public" "."] + 3002 ["public/workspaces" "."]} + :builds {:app {:target :browser :module-loader true :js-options {:ignore-asset-requires true} ;; handle `require(xxx.css)` - :modules {:common {:entries []} - - :main - {:init-fn frontend.core/init - :depends-on #{:code-editor :age-encryption :excalidraw}} + :modules {:main + {:init-fn frontend.core/init} ;; :graph ;; {:entries [frontend.extensions.graph.force] - ;; :depends-on #{:common}} + ;; :depends-on #{:main}} :code-editor {:entries [frontend.extensions.code] - :depends-on #{:common}} + :depends-on #{:main}} :age-encryption {:entries [frontend.extensions.age-encryption] - :depends-on #{:common}} + :depends-on #{:main}} :excalidraw {:entries [frontend.extensions.excalidraw] - :depends-on #{:common}}} + :depends-on #{:main}}} :output-dir "./static/js" :asset-path "/static/js" :release {:asset-path "https://asset.logseq.com/static/js"} @@ -35,11 +36,11 @@ :closure-defines {goog.debug.LOGGING_ENABLED true frontend.config/GITHUB_APP_NAME #shadow/env "GITHUB_APP2_NAME"} + :dev {:asset-path "js"} :devtools {:before-load frontend.core/stop ;; before live-reloading any code call this function :after-load frontend.core/start ;; after live-reloading finishes call this function - :http-root "public" - :http-port 3001 - :watch-path "static" + :watch-path "/static" + :watch-dir "static" :preloads [devtools.preload shadow.remote.runtime.cljs.browser]}} @@ -63,7 +64,7 @@ :compiler-options {:source-map false} :modules {:parser-worker {:entries [frontend.worker.parser] :web-worker true - :prepend #shadow/env ["PATCH_PARSER_WORKER" :default ";;"]}} + :prepend #shadow/env ["PATCH_PARSER_WORKER" :default ";;"]}} :release {:compiler-options {:infer-externs :auto}}} :test {:target :node-test @@ -74,25 +75,22 @@ :publishing {:target :browser :module-loader true :js-options {:ignore-asset-requires true} - :modules {:common {:entries []} - - :main - {:init-fn frontend.publishing/init - :depends-on #{:common}} + :modules {:main + {:init-fn frontend.publishing/init} ;; :graph ;; {:entries [frontend.extensions.graph.force] - ;; :depends-on #{:common}} + ;; :depends-on #{:main}} :code-editor {:entries [frontend.extensions.code] - :depends-on #{:common}} + :depends-on #{:main}} :age-encryption {:entries [frontend.extensions.age-encryption] - :depends-on #{:common}} + :depends-on #{:main}} :excalidraw {:entries [frontend.extensions.excalidraw] - :depends-on #{:common}}} - :output-dir "./static/js/publishing" - :asset-path "static/js" + :depends-on #{:main}}} + :output-dir "./static/js/publishing" + :asset-path "static/js" :closure-defines {frontend.config/PUBLISHING true goog.debug.LOGGING_ENABLED true} :compiler-options {:infer-externs :auto @@ -111,9 +109,8 @@ :preloads [] ;; optional, list namespaces to be pre loaded :devtools {:after-load nubank.workspaces.core/after-load :loader-mode :eval - :http-root "public/workspaces" - :http-port 3002 - :watch-path "static" + :watch-path "/static" + :watch-dir "static" :preloads [devtools.preload shadow.remote.runtime.cljs.browser]} :modules {:main {:entries [workspaces.main]}}}}}