如何使用Ionic 2为PWA和本机应用程序部署不同版本的index.html [英] How to deploy a different version of index.html for PWA and native Apps with Ionic 2

查看:97
本文介绍了如何使用Ionic 2为PWA和本机应用程序部署不同版本的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的PWA住在这里: https://m.quemesa.com 我们还有原生应用程序相同的代码库。

our PWA lives here: https://m.quemesa.com and we also have native apps with the same codebase.

但是,我们不是针对Cordova浏览器平台(因为它似乎没有得到官方支持,我看不出它增加了什么好处)因此,与我们的原生应用版本相比,我们必须为PWA添加略微不同的代码。例如,在PWA中,我们使用纯粹的Google Analytics解决方案,该解决方案在index.html中需要2行javascript。

However, we are not targeting the Cordova Browser platform (because it does not seem to be officially supported and I can’t see what benefit it adds) so we have to add slightly different code for our PWA compared to our native app builds. For example, In the PWA, we use the pure Google Analytics solution which requires 2 lines of javascript in the index.html.

对于我们的原生构建,我们使用Cordova GA插件,所以这不是必需的。在PWA中,我们不需要链接到Cordova.js和Vendor.js以获得exmaple(它们会出现404错误)。在我们的原生应用程序中。

For our native builds, we use the Cordova GA plugin, so this is not required. In the PWA we don’t need to link to Cordova.js and Vendor.js for exmaple (they get a 404 error). In the native apps we do.

目前我手动编辑(yuck)输出文件夹,然后上传到Azure for PWA。

Currently I am manually editing (yuck) the output folder before uploading to Azure for the PWA.

有没有办法编辑Ionic Build Process,以便我可以拥有2个版本的索引,并根据构建类型抓取它想要的输出文件夹,或者它可以修改html文件在构建时?

Is there some way to edit the Ionic Build Process so that I can either have 2 versions of the Index and it grabs the one it wants for the output folder depending on the build type OR it can modify the html file at build time?

推荐答案

目前的离子构建工具不支持此功能。

The current ionic build tool alone doesn't support this.

你可以只有2个版本的index.html和一个小脚本来交换它们并构建两个版本。

You could just have 2 versions of index.html and a small script to swap between them and build both versions.

这也是你可以做的事情使用完整CI构建工具。由于您提到Azure,您可以使用Visual Studio Team Services。现有任务可用于npm(安装离子,运行PWA构建)和运行命令/ PowerShell脚本。通过设置代理虚拟机可以更容易地开始构建应用程序(节点,离子,Android工作室等)所需的一切,然后从那里构建构建过程。

It's also something you could do with a "full" CI build tool. Since you mentioned Azure you could make use of Visual Studio Team Services. There are existing tasks available for npm (to install ionic, run a PWA build) and running command/PowerShell scripts. It may be easier to start off by setting up an "agent" VM with everything it needs to build your app (node, ionic, Android studio, etc) then build your build process up from there.

这篇关于如何使用Ionic 2为PWA和本机应用程序部署不同版本的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆