浏览代码

separate config for app and mobile

Tienson Qin 2 月之前
父节点
当前提交
7f18e941d0
共有 3 个文件被更改,包括 44 次插入15 次删除
  1. 1 0
      resources/mobile/index.html
  2. 8 2
      shadow-cljs.edn
  3. 35 13
      webpack.config.js

+ 1 - 0
resources/mobile/index.html

@@ -36,6 +36,7 @@ const portal = new MagicPortal(worker);
 <script defer src="./js/ui.js"></script>
 <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>

+ 8 - 2
shadow-cljs.edn

@@ -113,11 +113,17 @@
                                   shadow.remote.runtime.cljs.browser]}}
   :mobile {:target        :browser
            :module-loader true
-           :js-options    {:ignore-asset-requires true
+           :js-options    {:js-provider    :external
+                           :external-index "target/mobile.js"
+                           :external-index-format :esm
+                           :entry-keys ["module" "browser" "main"]
+                           :export-conditions ["module" "import", "browser" "require" "default"]
+                           :ignore-asset-requires true
                            :resolve {"react" {:target :global
                                               :global "React"}
                                      "react-dom" {:target :global
-                                                  :global "ReactDOM"}}} ;; handle `require(xxx.css)`
+                                                  :global "ReactDOM"}}}
+           ;; handle `require(xxx.css)`
            :modules       {:shared
                            {:entries []}
                            :main

+ 35 - 13
webpack.config.js

@@ -1,24 +1,12 @@
 const path = require('path');
 const webpack = require('webpack');
 
-module.exports = {
+var config = {
   mode: "development",
-  entry: {
-    main : "./target/main.js",
-    workers : "./target/workers.js"
-  },
-
   externals: {
     'react': 'React',
     'react-dom': 'ReactDOM',
   },
-
-  output: {
-    path: path.resolve(__dirname, 'static/js'),
-    filename: '[name]-bundle.js',
-    clean: false,
-    chunkLoading: false,
-  },
   module: {
     rules: [
       {
@@ -37,3 +25,37 @@ module.exports = {
     }),
   ],
 };
+
+var AppConfig = Object.assign({}, config, {
+  name: "app",
+  entry: {
+    main : "./target/main.js",
+    workers : "./target/workers.js",
+  },
+
+  output: {
+    path: path.resolve(__dirname, 'static/js'),
+    filename: '[name]-bundle.js',
+    clean: false,
+    chunkLoading: false,
+  },
+});
+
+var MobileConfig = Object.assign({}, config, {
+  name: "app",
+  entry: {
+    main : "./target/mobile.js",
+    workers : "./target/workers.js",
+  },
+
+  output: {
+    path: path.resolve(__dirname, 'static/mobile/js'),
+    filename: '[name]-bundle.js',
+    clean: false,
+    chunkLoading: false,
+  },
+});
+
+module.exports = [
+  AppConfig, MobileConfig,
+];