We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web 和小程序中 app.json 相关的配置存在差异性,比如 tarbbar 或者 title
tarbbar
title
阿里小程序 target 均为 miniapp,以业务同时需要构建淘宝小程序、支付宝小程序为例,目前的设计每次构建都只能使用同一份 app.json,但实际上可能存在 tabbar 等配置不同的情况
target
miniapp
app.json
tabbar
在移除 document/index.jsx 之后,如果存在 <script> var a = 1 </script> 这种类似需要插入的脚本,现有的 json 文件难以承载
document/index.jsx
<script> var a = 1 </script>
app.json 允许端差异化配置,比如:
{ "window": { "title": "Rax App" }, "miniapp": { "window": { "title": "Rax MiniApp" } } }
用户在根对象下设置基础配置,对应不同端的配置采用深合并的方式实现,例如:
{ "routes": [ { "path": "/", "name": "home", "source": "pages/Home/index" }, { "path": "/about", "name": "about", "source": "pages/About/index" } ], "miniapp": { "routes": [ {}, { "source": "page/MiniAppAbout/index" } ] } }
在构建时生成差异化的 app.json 以实现差异化构建。
通过后缀名区分不同端的 app.json,比如:
app.json:
{ "window": { "title": "Rax App" } }
app.miniapp.json:
{ "window": { "title": "Rax MiniApp" } }
与方案一一致,在 app.json 中仅设置基础配置,在不同端的 app.json 中配置差异化的配置,最终进行深合并,例如:
{ "routes": [ { "path": "/", "name": "home", "source": "pages/Home/index" }, { "path": "/about", "name": "about", "source": "pages/About/index" } ], }
{ "routes": [ {}, { "source": "page/MiniAppAbout/index" } ] }
json
新增 app.config.js 概念,在 node 端执行,传入当前构建的 target,可以使用 process.env 根据启动的环境变量动态获取值,比如:
app.config.js
process.env
module.exports = target => { return { title: target === 'miniapp' && process.env.IS_TAO_BAO ? 'Rax TaoBao MiniApp' : 'Rax App' } }
route
targets
The text was updated successfully, but these errors were encountered:
方案三可以支持 ts/esm,只需要通过 swc/esbuild 预构建一下就好了
Sorry, something went wrong.
No branches or pull requests
背景
需求 1:已有 target 分端构建
web 和小程序中 app.json 相关的配置存在差异性,比如
tarbbar
或者title
需求 2:阿里小程序分端构建
阿里小程序
target
均为miniapp
,以业务同时需要构建淘宝小程序、支付宝小程序为例,目前的设计每次构建都只能使用同一份app.json
,但实际上可能存在tabbar
等配置不同的情况需求 3:移除 Document 之后自定义脚本插入问题
在移除
document/index.jsx
之后,如果存在<script> var a = 1 </script>
这种类似需要插入的脚本,现有的 json 文件难以承载方案
方案一(改进后)
app.json
允许端差异化配置,比如:用户在根对象下设置基础配置,对应不同端的配置采用深合并的方式实现,例如:
在构建时生成差异化的
app.json
以实现差异化构建。优势
app.json
这个文件中,不会有新增实体的认知劣势
app.json
可能会变得非常庞大难以维护方案二(改进后)
通过后缀名区分不同端的
app.json
,比如:app.json:
app.miniapp.json:
与方案一一致,在
app.json
中仅设置基础配置,在不同端的app.json
中配置差异化的配置,最终进行深合并,例如:app.json:
app.miniapp.json:
优势
json
的配置形式,分文件的形式可以让配置信息维护起来更容易劣势
方案三
新增
app.config.js
概念,在 node 端执行,传入当前构建的target
,可以使用process.env
根据启动的环境变量动态获取值,比如:优势
劣势
遗留问题
route
里目前的targets
字段是不是没有意义了?The text was updated successfully, but these errors were encountered: