从角度环境中排除文件 [英] Exclude files from angular environment

查看:33
本文介绍了从角度环境中排除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个安装在不同客户端的应用程序.为此,我使用了不同的环境,例如

I am building an application that I install in different clients. For this, I am using different enviroments, for example

environment.costumer1.tsenvironment.costumer2.ts

environment.costumer1.ts environment.costumer2.ts

事实是有些客户使用服务工作者而另一些客户没有,所以我创建了两个不同的 app.module.ts

The fact is that some customers use Services Workers and another does not, so I have created two different app.module.ts

app.module.ts
app.module-without-service-worker.ts

因此,当客户要求我提供一个没有 Service Worker 的应用程序时(我使用了一个通知服务,我不想显示谁不想要它)我把它放在 angular.json 中的 fileReplacements 中

So, when a client asks me for an application without Service Worker (I use a notification service that I do not want to show who does not want it) I put it in angular.json, inside fileReplacements

{   
  "replace": "src / app / app.module.ts",
  "with": "src / app / app.module-without-service-worker.ts" 
}

不好的是,在构建主应用程序时,我收到以下错误:

The bad thing is that when doing a build of the main application I get the following error:

ERROR in: Type AppComponent in D:/development/Patient Portal/患者门户演示/pp演示前面/src/app/app.component.ts是2个模块的部分声明:D:/developments中的AppModule/患者门户/患者门户演示/pp 演示前端/src/app/app.module.ts 和 AppModule in D:/development/Patient Portal/患者门户演示/pp 演示前面/src/app/app.module-没有-service-worker.ts!

ERROR in: Type AppComponent in D: / developments / Patient Portal / patient-portal-demo / pp demo front / src / app / app.component.ts is part of the declarations of 2 modules: AppModule in D: / developments / Patient Portal / patient-portal-demo / pp demo front / src / app / app.module.ts and AppModule in D: / developments / Patient Portal / patient-portal-demo / pp demo front / src / app / app.module- without-service-worker.ts!

有没有办法从环境中排除文件?

Is there a way to exclude files from an enviroment?

推荐答案

如果 client1 和 client2 有单独的构建,那么你可以简单地做以下事情

If there is a separate build for client1 and client2 then you can simply do the following things

打开angular.json文件,找到那行

Open the angular.json file and find the line

"serviceWorker": true

如果您想激活 Service Worker,则该值为 true 否则为 false.

If you want to active service worker then the value is true else false.

这篇关于从角度环境中排除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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