Angular6自定义environment配置

本文介绍如何在Angular6及以上版本中配置自定义环境变量。通过修改angular.json文件,可以轻松切换不同的环境配置,比如开发环境、生产环境及特定环境,如zhizhongbao环境。
Angular6以往版本自定义environment配置在.angular-cli.json文件中,
    1、在.angular-cli.json文件中 “environments中"添加
    例如:
        "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts",
            "zhizhongbao": "environments/environment.zhizhongbao.ts"
        }
    2、编译命令
        ng build --base-href /saturn/ --prod --env=zhizhongbao
Angular6.x版本后,.angular-cli.json文件演变成angular.json文件
如果需要加自定义配置文件environment.zhizhongbao.ts
1、在angular.json文件中如下配置:
      "configurations": {
          "production": {
                "fileReplacements": [
                    {
                        "replace": "src/environments/environment.ts",
                        "with": "src/environments/environment.prod.ts"
                      }
                ],
                "optimization": true,
                "outputHashing": "all",
                "sourceMap": false,
                "extractCss": true,
                "namedChunks": false,
                "aot": true,
                "extractLicenses": true,
                "vendorChunk": false,
                "buildOptimizer": true
                },
        "zhizhongbao": {
            "fileReplacements": [
                 {
                    "replace": "src/environments/environment.ts",
                    "with": "src/environments/environment.zhizhongbao.ts"
                  }
                ],
                "optimization": true,
                "outputHashing": "all",
                "sourceMap": false,
                "extractCss": true,
                "namedChunks": false,
                "aot": true,
                "extractLicenses": true,
                "vendorChunk": false,
                "buildOptimizer": true
            }
        }
    2、无任何配置,默认编译prod命令
               ng build --base-href /myweb/ --prod  --configuration=production
          如需使用zhizhongbao环境,则执行命令
                ng build --base-href /myweb/ --prod  --configuration=zhizhongbao
    
A hands-on guide with a minimalist and flexible approach that enables quick learning and rapid delivery of cloud-ready enterprise applications with Angular 6 Key Features Explore tools and techniques to push your web app to the next level Master Angular app design and architectural considerations Learn continuous integration and deploy your app on a highly available cloud infrastructure in AWS Book Description Angular 6 for Enterprise-Ready Web Applications follows a hands-on and minimalist approach demonstrating how to design and architect high quality apps. The first part of the book is about mastering the Angular platform using foundational technologies. You will use the Kanban method to focus on value delivery, communicate design ideas with mock-up tools and build great looking apps with Angular Material. You will become comfortable using CLI tools, understand reactive programming with RxJS, and deploy to the cloud using Docker. The second part of the book will introduce you to the router-first architecture, a seven-step approach to designing and developing mid-to-large line-of-business applications, along with popular recipes. You will learn how to design a solid authentication and authorization experience; explore unit testing, early integration with backend APIs using Swagger and continuous integration using CircleCI. In the concluding chapters, you will provision a highly available cloud infrastructure on AWS and then use Google Analytics to capture user behavior. By the end of this book, you will be familiar with the scope of web development using Angular, Swagger, and Docker, learning patterns and practices to be successful as an individual developer on the web or as a team in the Enterprise. What you will learn Create full-stack web applications using Angular and RESTful APIs Master Angular fundamentals, RxJS, CLI tools, unit testing, GitHub, and Docker Design and architect responsive, secure and scalable apps to deploy on AWS Adopt a minimalist,
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值