Browse Source

fix: mobile build

Tienson Qin 2 tháng trước cách đây
mục cha
commit
88dfaf8ebd
5 tập tin đã thay đổi với 91 bổ sung31 xóa
  1. 87 0
      externs/mobile.txt
  2. 2 2
      package.json
  3. 0 1
      resources/mobile/index.html
  4. 2 10
      shadow-cljs.edn
  5. 0 18
      src/dev-cljs/shadow/hooks.clj

+ 87 - 0
externs/mobile.txt

@@ -0,0 +1,87 @@
+require
+DEBUG
+convertFileSrc
+getPlatform
+handleError
+isLoggingEnabled
+isNative
+isNativePlatform
+isPluginAvailable
+platform
+pluginMethodNoop
+registerPlugin
+registerHelper
+Pass
+showHint
+createRef
+call
+setState
+forceUpdate
+memo
+createElement
+render
+unmount
+createContext
+createPortal
+createRef
+createElement
+ref
+path
+current
+useState
+useReducer
+useEffect
+useLayoutEffect
+useCallback
+useMemo
+useRef
+renderToString
+idb-keyval
+newStore
+isError
+value
+CodeMirror
+over
+forEachNode
+on
+getTextArea
+setUser
+nativeEvent
+which
+multipliedBy
+minus
+plus
+isInteger
+isPositive
+isLessThan
+toNumber
+modulo
+exponentiatedBy
+dividedBy
+multipliedBy
+negated
+isZero
+isGreaterThanOrEqualTo
+isLessThan
+shiftedBy
+s
+dividedToIntegerBy
+abs
+toFraction
+e
+getCursor
+getLineTokens
+getTokenAt
+getValue
+completionActive
+state
+mime
+getWrapperElement
+doc
+lastLine
+getLine
+setOption
+string
+dispose
+path
+base64String

+ 2 - 2
package.json

@@ -78,8 +78,8 @@
         "gulp:mobile-watch": "gulp watchMobile",
         "css:mobile-build": "postcss tailwind.mobile.css -o static/mobile/style.css --verbose --env production",
         "css:mobile-watch": "cross-env TAILWIND_MODE=watch postcss tailwind.mobile.css -o static/mobile/style.css --verbose --watch",
-        "cljs:mobile-watch": "clojure -M:cljs watch mobile workers",
-        "cljs:release-mobile": "clojure -M:cljs release mobile workers",
+        "cljs:mobile-watch": "clojure -M:cljs watch mobile workers --config-merge \"{:output-dir \\\"./static/mobile/js\\\" :asset-path \\\"/static/mobile/js\\\" :release {:asset-path \\\"http://localhost\\\"}}\"",
+        "cljs:release-mobile": "clojure -M:cljs release mobile workers --config-merge \"{:output-dir \\\"./static/mobile/js\\\" :asset-path \\\"/static/mobile/js\\\" :release {:asset-path \\\"http://localhost\\\"}}\"",
         "cljs:dev-watch": "clojure -M:cljs watch app workers electron mobile",
         "cljs:app-watch": "clojure -M:cljs watch app workers",
         "cljs:electron-watch": "clojure -M:cljs watch app workers electron --config-merge \"{:asset-path \\\"./js\\\"}\"",

+ 0 - 1
resources/mobile/index.html

@@ -37,7 +37,6 @@ const portal = new MagicPortal(worker);
 <script defer src="./js/amplify.js"></script>
 <script defer src="./ionic.js"></script>
 <script defer src="./js/main-bundle.js"></script>
-<script defer src="./js/shared.js"></script>
 <script defer src="./js/main.js"></script>
 <script>
   document.addEventListener('DOMContentLoaded', () => {

+ 2 - 10
shadow-cljs.edn

@@ -101,11 +101,6 @@
                                           :redef false}
                                :cross-chunk-method-motion false}
             :closure-defines {goog.debug.LOGGING_ENABLED true}
-
-            ;; NOTE: electron, browser/mobile-app use different asset-paths.
-            ;;   For browser/mobile-app devs, assets are located in /static/js(via HTTP root).
-            ;;   For electron devs, assets are located in ./js(via relative path).
-            ;; :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
                        :watch-path "/static"
@@ -124,11 +119,8 @@
                                      "react-dom" {:target :global
                                                   :global "ReactDOM"}}}
            ;; handle `require(xxx.css)`
-           :modules       {:shared
-                           {:entries []}
-                           :main
-                           {:init-fn mobile.core/init
-                            :depends-on #{:shared}}
+           :modules       {:main
+                           {:init-fn mobile.core/init}
                            :code-editor
                            {:entries [frontend.extensions.code]
                             :depends-on #{:main}}}

+ 0 - 18
src/dev-cljs/shadow/hooks.clj

@@ -12,24 +12,6 @@
         (string/trim out))
       (println err))))
 
-(defn purge-css
-  {:shadow.build/stage :flush}
-  [state {:keys [css-source
-                 js-globs
-                 public-dir]}]
-  (case (:shadow.build/mode state)
-    :release
-    (exec "purgecss --css " css-source
-          (for [content (if (string? js-globs) [js-globs] js-globs)]
-            (str "--content " content))
-          "-o" public-dir)
-
-    :dev
-    (do
-      (exec "mkdir -p" public-dir)
-      (exec "cp" css-source (str public-dir "/" (last (string/split css-source #"/"))))))
-  state)
-
 (defn git-revision-hook
   {:shadow.build/stage :configure}
   [build-state & args]